0.2.1 • Published 3 years ago

@leaf-x/id v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Snowflake

Twitter snowflake algorithm, using TypeScript implementation.

Installation

npm install @leaf-x/snowflake --save

Parameters

NameTypeDefault ValueDescription
dataCenterIdNumber0Data center id.
workerIdNumber0Work machine id.
twEpochNumberRequiredStart timestamp.

Usage

import * as snowflake from '@leaf-x/snowflake'

const generateId = snowflake({
  dataCenterId: 0,
  workerId: 0,
  twEpoch: 1583734327332
})

const id = generateId()

console.info(id)
0.2.1

3 years ago

0.2.0

3 years ago