JSPM

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

Example usage

import Snowlyflake, { EPOCHS }  from './';

console.log(new Snowlyflake);

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

const snowflake = snowlyflake.nextId();

console.log('Snowflake', snowflake); // => 525232527980494849n

const deconstructSnowflake = snowlyflake.deconstruct(snowflake);

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