A WebAssembly implementation of UUID v1 generator and parser
Supports both ESM an CommonJS
🏠 Homepage
The Fastest UUID v1 Parser and Generator for NodeJS.
The results were obtained by running each function inconsistently 1,000,000 times with NodeJS v20.8.1, R7 6800H, 16g DDR5
Parsing (string --> Data) | Average, ops | Median, ops |
---|---|---|
[email protected] unsafe | 4,414,844 ± 4.27 % | 4,524,905 ± 5.26 % |
[email protected] safe | 3,884,245 ± 2.24 % | 3,984,022 ± 2.46 % |
[email protected] | ----- | ----- |
[email protected] | 906,154 ± 5.43 % | 924,215 ± 6.76 % |
Generate (--> string) | Average, ops | Median, ops |
---|---|---|
[email protected] | 6,516,927 ± 10.13 % | 6,584,145 ± 12.64 % |
[email protected] | 3,705,620 ± 7.15 % | 3,785,155 ± 9.99 % |
[email protected] | 278,435 ± 6.48 % | 286,600 ± 9.92 % |
- node >=14.21.3
npm i uuid-wasm
import { InitUUID } from 'uuid-wasm';
const run = async () => {
const { v1, nanos, timeFromV1, unsafeTimeFromV1 } = await InitUUID();
const uuid = v1();
console.log(uuid);
// 6335ff92-6a7a-11ee-929a-eedc63b9d38e
const nanoseconds = nanos();
console.log(nanoseconds);
// 1697278437810573000n
const date1 = timeFromV1(uuid);
console.log(date1);
// 2023-10-14T10:13:57.810Z
console.log(date1.getTime());
// 1697278547627
const date2 = unsafeTimeFromV1(uuid);
console.log(date2);
// 2023-10-14T10:13:57.810Z
console.log(date2.getTime());
// 1697278547627
};
run().catch(console.error);
Sergey Saltykov
- Github: @mishimastar
- Email: [email protected]
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Copyright © 2023 Sergey Saltykov.
This project is MIT licensed.