Skip to content

Commit 7b98d48

Browse files
committed
docs: add README
1 parent 60636d6 commit 7b98d48

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Diff for: packages/native-machine-id/README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ npx native-machine-id --raw
2020
### As a module
2121

2222
```javascript
23-
import { getMachineID } from 'native-machine-id';
23+
import { getMachineId } from 'native-machine-id';
2424

25-
// Get the machine ID
25+
// Get the machine ID, hashed with SHA-256
2626
const hashedId = getMachineID();
27-
console.log('SHA-256 Hashed Machine ID:', hashedId);
27+
console.log('Hashed Machine ID:', hashedId);
28+
29+
// Get the raw machine ID (should not be exposed in untrusted environments)
2830
const rawId = getMachineID({ raw: true });
2931
console.log('Original Machine ID:', rawId);
32+
33+
// Or synchronously
34+
import { getMachineIdSync } from 'native-machine-id';
35+
const id = getMachineIdSync();
3036
```
3137

3238
## Supported Platforms
@@ -39,7 +45,7 @@ console.log('Original Machine ID:', rawId);
3945

4046
This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id) while **using native access to system APIs without the need for child processes**, making it much faster and reliable.
4147

42-
Here's a table of performance comparisons between the two libraries, based on the average runtime from 1000 iterations of the `getMachineId` and `machineIdSync` functions, from `scripts/benchmark.ts`:
48+
Here's a table of performance comparisons between the two libraries, based on the average runtime from 1000 iterations of the `getMachineIdSync` and `machineIdSync` functions, from `scripts/benchmark.ts`:
4349

4450
| Test | node-machine-id | native-machine-id | Improvement |
4551
| ----------- | --------------- | ----------------- | ----------- |
@@ -61,10 +67,10 @@ If you were previously using `node-machine-id`, you can use the following mappin
6167

6268
```ts
6369
import { createHash } from 'crypto';
64-
import { getMachineId } from 'native-machine-id';
70+
import { getMachineIdSync } from 'native-machine-id';
6571

6672
function machineIdSync(original: boolean): string | undefined {
67-
const rawMachineId = getMachineId({ raw: true }).toLowerCase();
73+
const rawMachineId = getMachineIdSync({ raw: true }).toLowerCase();
6874

6975
return original
7076
? rawMachineId

0 commit comments

Comments
 (0)