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

2.0.0 • Public • Published

NPM version Build Status NPM downloads Code quality

Snowyflake - A modern implementation Snowflake on TypeScript

📖 Documentation

Installation

Node.js 16.0.0 or newer is required

TypeScript config required "targer": "ES2019" or higher

Yarn

Recommended

yarn add snowyflake

NPM

npm i snowyflake

Example usage

import { Snowyflake, Epoch } from 'snowyflake';

const snowyflake = new Snowyflake({
	workerId: 1n,
	epoch: Epoch.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 }

Package Sidebar

Install

npm i snowyflake

Weekly Downloads

1,285

Version

2.0.0

License

MIT

Unpacked Size

15.1 kB

Total Files

12

Last publish

Collaborators

  • negezor