1.0.6 • Published 3 years ago

snowflake_builder v1.0.6

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

snowflake-generator

An example and a lightweight is the Twitter and Discord snowflake generator.

Getting Started

Install the npm package

Installation

npm install snowflake_builder

Require the package into your code

const { Snowflake } = require('snowflake_builder')

Construct a new Snowflake Generator with the EPOCH timestamp in milliseconds

const Generator = new Snowflake();

Generate a Snowflake

const newSnowflake = Generator.createSnowflake();

Snowflake (class)

Constructor

new Snowflake(dataCenter?: number[], machineId?: number[]);

paramtypeoptionaldefaultdescription
dataCenternumber[]trueundefinedThe ids of the data centers you have. You can optionally give an array of random numbers.
machineIdnumber[]trueundefinedthe ids of the machines you have. You can optionally give an array of random numbers.

Properties

- dataCenter

IDs of data centers

@type number

- machineId

IDs of machines

@type number

Methods

Generate Snowflakes. You can create a total of 4096 snowflakes in 1 millisecond.

Generator.createSnowflake(dCenterId?: number, machineId?: number)

paramtypeoptionaldefaultdescription
dCenterIdnumbertrueundefinedWhich data center was created using.
machineIdnumbertrueundefinedWhich machine was created using.

@returns string

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago