Package Exports
- snowyflake
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (snowyflake) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Snowyflake - A modern implementation Snowflake on TypeScript
| 📖 Documentation |
|---|
Installation
Node.js 10.16.0 or newer is required
TypeScript config required
"targer": "esnext"
Yarn
Recommended
yarn add snowyflakeNPM
npm i snowyflakeExample usage
import { Snowyflake, Epochs } from 'snowyflake';
const snowyflake = new Snowyflake({
workerId: 1n,
epoch: Epochs.TWITTER // BigInt timestamp
});
const snowflake = snowyflake.nextId();
console.log(snowflake); // => 1075766315999952896n
const deconstructSnowflake = snowyflake.deconstruct(snowflake);
console.log(deconstructSnowflake); // =>
// { timestamp: 1545317651163n,
// workerId: 1n,
// processId: 0n,
// sequence: 0n }