1.0.6 • Published 3 years ago
snowflake_builder v1.0.6
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[]);
param | type | optional | default | description |
---|---|---|---|---|
dataCenter | number[] | true | undefined | The ids of the data centers you have. You can optionally give an array of random numbers. |
machineId | number[] | true | undefined | the 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)
param | type | optional | default | description |
---|---|---|---|---|
dCenterId | number | true | undefined | Which data center was created using. |
machineId | number | true | undefined | Which machine was created using. |
@returns string