uuid-wasm
A WebAssembly implementation of UUID v1 generator and parser
Supports both ESM an CommonJS
About
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 |
---|
uuid-wasi@0.2.0 unsafe | 4,414,844 ± 4.27 % | 4,524,905 ± 5.26 % |
uuid-wasi@0.2.0 safe | 3,884,245 ± 2.24 % | 3,984,022 ± 2.46 % |
uuid@9.0.0 | ----- | ----- |
cassandra-driver@4.6.4 | 906,154 ± 5.43 % | 924,215 ± 6.76 % |
Generate (--> string) | Average, ops | Median, ops |
---|
uuid-wasi@0.2.0 | 6,516,927 ± 10.13 % | 6,584,145 ± 12.64 % |
uuid@9.0.0 | 3,705,620 ± 7.15 % | 3,785,155 ± 9.99 % |
cassandra-driver@4.6.4 | 278,435 ± 6.48 % | 286,600 ± 9.92 % |
Prerequisites
Install
npm i uuid-wasm
Usage
import { InitUUID } from 'uuid-wasm';
const run = async () => {
const { v1, nanos, timeFromV1, unsafeTimeFromV1 } = await InitUUID();
const uuid = v1();
console.log(uuid);
const nanoseconds = nanos();
console.log(nanoseconds);
const date1 = timeFromV1(uuid);
console.log(date1);
console.log(date1.getTime());
const date2 = unsafeTimeFromV1(uuid);
console.log(date2);
console.log(date2.getTime());
};
run().catch(console.error);
Author
Sergey Saltykov
Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
License
Copyright © 2023 Sergey Saltykov.
This project is MIT licensed.