Class: Snowflake
A class for generating and deconstructing Twitter snowflakes.
A Twitter snowflake is a 64-bit unsigned integer with 4 fields that have a fixed epoch value.
If we have a snowflake 266241948824764416 we can represent it as binary:
64 22 17 12 0
000000111011000111100001101001000101000000 00001 00000 000000000000
number of ms since epoch worker pid increment
Constructors
new Snowflake()
Parameters
| Parameter | Type | Description |
|---|---|---|
epoch | number | bigint | Date | the epoch to use |
Returns
Source
Properties
[EpochSymbol]
Internal
privatereadonly[EpochSymbol]:bigint
Internal reference of the epoch passed in the constructor
Source
[IncrementSymbol]
Internal
private[IncrementSymbol]:bigint
Internal incrementor for generating snowflakes