Skip to content

Commit f0763b0

Browse files
authored
docs: better naming and description for native-machine-id (#528)
1 parent ce77397 commit f0763b0

19 files changed

+140
-91
lines changed

package-lock.json

Lines changed: 93 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/machine-id/README.md renamed to packages/native-machine-id/README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
# @mongodb-js/machine-id
1+
# native-machine-id
22

3-
> Native implementation for retrieving unique machine ID without admin privileges or child processes for desktop platforms. Faster and more reliable alternative to node-machine-id.
3+
> Native retrieval of a unique desktop machine ID without admin privileges or child processes. Faster and more reliable alternative to node-machine-id.
44
55
## Installation
66

77
```
8-
npm install @mongodb-js/machine-id
8+
npm install native-machine-id
99
```
1010

1111
Or use it directly in the CLI
1212

1313
```
14-
npx @mongodb-js/machine-id
14+
npx native-machine-id
15+
npx native-machine-id --raw
1516
```
1617

1718
## Usage
1819

1920
### As a module
2021

2122
```javascript
22-
import { getMachineID } from '@mongodb-js/machine-id';
23+
import { getMachineID } from 'native-machine-id';
2324

2425
// Get the machine ID
2526
const hashedId = getMachineID();
26-
console.log('SHA-256 Hashed Machine ID:', id);
27-
const id = getMachineID({ raw: true });
28-
console.log('Original Machine ID:', id);
27+
console.log('SHA-256 Hashed Machine ID:', hashedId);
28+
const rawId = getMachineID({ raw: true });
29+
console.log('Original Machine ID:', rawId);
2930
```
3031

3132
## Supported Platforms
@@ -36,21 +37,21 @@ console.log('Original Machine ID:', id);
3637

3738
## Comparison with `node-machine-id`
3839

39-
This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but **using native access to system APIs without the need for child processes**, making it much faster and reliable.
40+
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.
4041

4142
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`:
4243

43-
| Test | node-machine-id | @mongodb-js/machine-id | Improvement |
44-
| ----------- | --------------- | ---------------------- | ----------- |
44+
| Test | node-machine-id | native-machine-id | Improvement |
45+
| ----------- | --------------- | ----------------- | ----------- |
4546
| **Mac** |
46-
| Raw | 10.71ms | 0.0072ms | 1494x |
47-
| Hashed | 12.42ms | 0.0176ms | 707x |
47+
| Raw | 10.71ms | 0.0072ms | 1494x |
48+
| Hashed | 12.42ms | 0.0176ms | 707x |
4849
| **Linux** |
49-
| Raw | 3.26ms | 0.0059ms | 557x |
50-
| Hashed | 3.25ms | 0.0088ms | 368x |
50+
| Raw | 3.26ms | 0.0059ms | 557x |
51+
| Hashed | 3.25ms | 0.0088ms | 368x |
5152
| **Windows** |
52-
| Raw | 45.36ms\* | 0.0122ms | 3704x |
53-
| Hashed | 28.66ms\* | 0.0272ms | 1053x |
53+
| Raw | 45.36ms\* | 0.0122ms | 3704x |
54+
| Hashed | 28.66ms\* | 0.0272ms | 1053x |
5455

5556
\* - Windows tests may be inaccurate due to potential caching.
5657

@@ -60,7 +61,7 @@ If you were previously using `node-machine-id`, you can use the following mappin
6061

6162
```ts
6263
import { createHash } from 'crypto';
63-
import { getMachineId } from '@mongodb-js/machine-id';
64+
import { getMachineId } from 'native-machine-id';
6465

6566
function machineIdSync(original: boolean): string | undefined {
6667
const rawMachineId = getMachineId({ raw: true }).toLowerCase();
File renamed without changes.

0 commit comments

Comments
 (0)