@litert/[email protected]

该文章根据 CC-BY-4.0 协议发表,转载请遵循该协议。
本文地址:https://fenying.net/en/project/litert/uuid/v2.0.0/

A uuid generator library for NodeJS, written in TypeScript.

v2.0.0 Changes

  • feat(algo): added implements of UUIDv4 algorithm.
  • feat(algo): added implements of UUIDv5 algorithm.
  • fix(algo): allow Snowflake using custom epoch.
  • fix(algo): implement Snowflake-SI with more customization options.
  • deprecate(algo): removed the Snowflake-SI-vA algorithm, which is no longer recommended.
  • test(project): added unit tests.
  • deprecate(deps): removed all runtime dependencies.

Requirement

  • TypeScript v5.0.0 (or newer)
  • Node.js v18.0.0 (or newer)

Installation

Install by NPM:

1npm i @litert/uuid --save

Documents

Algorithms

  • Snowflake

    A 64-bit integer UUID algorithm provided by X (Twitter).

  • Snowflake-SI

    The Snowflake-SI algorithm generates safe integer (53-bits integer) for JavaScript, with capacity 128 uuids per milliseconds, and 64 machine parallel working.

  • UUIDv4

    The UUID version 4 algorithm generates random UUIDs.

  • UUIDv5

    The UUID version 5 algorithm generates UUIDs based on SHA-1 hash of a namespace and a name.

Examples

License

This library is published under Apache-2.0 license.