Class: Catflake

catflake~Catflake(options)

Class representing a snowflake factory

Constructor

new Catflake(options)

Create a Catflake factory
Parameters:
Name Type Description
options object The options to configure Catflake with
Properties
Name Type Attributes Default Description
epoch number <optional>
1420070400000 The epoch to subtract from the timestamp
incrementBits number <optional>
12 The max number of bits that the increment can span
workerBits number <optional>
12 The max number of bits that the workerId can span
processBits number <optional>
12 The max number of bits that the processId can span
processId number <optional>
12 The process ID to generate snowflakes for
workerBits number <optional>
12 The worker ID to generate snowflakes for
async boolean <optional>
false When true, generate snowflakes asyncronously (eliminates duplicates, but slightly slower)
stringify boolean <optional>
true When true, returns a string for snowflakes. Otherwise, returns a BigInteger object
Source:

Methods

deconstruct(snowflake) → {DeconstructedSnowflake}

Deconstructs a snowflake
Parameters:
Name Type Description
snowflake string | number | BigInteger The snowflake to deconstruct
Source:
Returns:
Type
DeconstructedSnowflake

generate() → {string|BigInteger|Promise.<(string|BigInteger)>}

Generates a snowflake
Source:
Returns:
Type
string | BigInteger | Promise.<(string|BigInteger)>