0.3.1 • Published 7 months ago

uuid-wasm v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

A WebAssembly implementation of UUID v1 generator and parser

Supports both ESM an CommonJS

🏠 Homepage

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, opsMedian, ops
uuid-wasi@0.2.0 unsafe4,414,844 ± 4.27 %4,524,905 ± 5.26 %
uuid-wasi@0.2.0 safe3,884,245 ± 2.24 %3,984,022 ± 2.46 %
uuid@9.0.0----------
cassandra-driver@4.6.4906,154 ± 5.43 %924,215 ± 6.76 %

Generate (--> string)Average, opsMedian, ops
uuid-wasi@0.2.06,516,927 ± 10.13 %6,584,145 ± 12.64 %
uuid@9.0.03,705,620 ± 7.15 %3,785,155 ± 9.99 %
cassandra-driver@4.6.4278,435 ± 6.48 %286,600 ± 9.92 %

Prerequisites

  • node >=14.21.3

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);
    // 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);

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.

0.3.0

7 months ago

0.3.1

7 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.6

7 months ago

0.1.5

7 months ago

0.1.4

7 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago