snowflake-worker
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

SnowflakeWorker

License Latest npm release NPM downloads

一个 JavaScript 或 Node 雪花 ID 生成器。 A JavaScript or Node snowflake ID generator.

安装

npm 安装

npm i snowflake-worker -S

yarn 安装

yarn add snowflake-worker -S

pnpm 安装

pnpm i snowflake-worker -S

使用

import SnowflakeWorker from 'snowflake-worker'

const snowflakeWorker = new SnowflakeWorker(1, 1)
const snowflakeId = snowflakeWorker.nextId()

// 或者使用全局唯一雪花对象(全局唯一雪花对象一经创建后不能被修改,重复调用 global 方法不会覆盖)
const snowflakeWorkerGlobal = SnowflakeWorker.global(1, 1)
const snowflakeId2 = snowflakeWorkerGlobal.nextId()

Package Sidebar

Install

npm i snowflake-worker

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

20.7 kB

Total Files

8

Last publish

Collaborators

  • jl15988