Skip to content

JavaScript library for Twitter's Snowflake implementation

License

Notifications You must be signed in to change notification settings

JasonDevTech/snowflakejs

Repository files navigation

snowflakejs

SnowflakeJS is a Twitter snowflake generator and deconstructor for JavaScript.

npm npm CircleCI Maintenance

Installation

$ yarn add @semperfortis/snowflakejs

Usage

Generate a snowflake

import { generate } from '@semperfortis/snowflakejs';

// optional epoch, defaults to current date
const snowflake = generate({ epoch: 1577833200000 });

console.log(snowflake);

Return snowflake creation date

import { deconstruct } from '@semperfortis/snowflakejs';

// optional epoch, defaults to current date
const date = deconstruct(snowflake, { epoch: 1577833200000 });

console.log(date);

About

JavaScript library for Twitter's Snowflake implementation

Topics

Resources

License

Stars

Watchers

Forks