1.1.2 • Published 3 years ago

sonyflake v1.1.2

Weekly downloads
141
License
MIT
Repository
github
Last release
3 years ago

Sonyflake - A modern implementation Sonyflake on TypeScript

📖 Documentation

Installation

Node.js 10.16.0 or newer is required

Yarn

Recommended

yarn add sonyflake

NPM

npm i sonyflake

Example usage

import { Sonyflake, Epochs } from 'sonyflake';

const sonyflake = new Sonyflake({
  machineId: 2, // in range 2^16
  epoch: Date.UTC(2020, 4, 18, 0, 0, 0), // timestamp
});

const snowflake = sonyflake.nextId();

console.log(snowflake); // => "1211144891006978"

const deconstructSnowflake = sonyflake.deconstruct(snowflake);

console.log(deconstructSnowflake); // =>
// { timestamp: 1589832189861,
// 	machineId: 2,
// 	sequence: 0 }
1.1.1

3 years ago

1.1.0

3 years ago

1.1.2

3 years ago

1.0.1

5 years ago

1.0.2

5 years ago