JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2457
  • Score
    100M100P100Q118189F
  • License MIT

A modern implementation Snowflake on TypeScript

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

NPM version Build Status NPM downloads Code quality

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 snowyflake

NPM

npm i snowyflake

Example 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 }