JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2190
  • Score
    100M100P100Q118036F
  • 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

Example usage

import { Snowlyflake, Epochs } from 'snowyflake';

const snowlyflake = new Snowlyflake({
    workerId: 1n,
    epoch: Epochs.TWITTER // BigInt timestamp
});

const snowflake = snowlyflake.nextId();

console.log(snowflake); // => 1075766315999952896n

const deconstructSnowflake = snowlyflake.deconstruct(snowflake);

console.log(deconstructSnowflake); // =>
// { timestamp: 1545317651163n,
// 	workerId: 1n,
// 	processId: 0n,
// 	sequence: 0n }