Snowflake
Snowflake
Section titled “Snowflake”Represents a Snowflake, a unique identifier used in distributed systems.
Kind: global class
- Snowflake
- .deconstruct(snowflake) ⇒
Object - .generate([timestamp]) ⇒
string
- .deconstruct(snowflake) ⇒
Snowflake.deconstruct(snowflake) ⇒ Object
Section titled “Snowflake.deconstruct(snowflake) ⇒ Object”Deconstructs a Discord snowflake into its individual components.
Kind: static method of Snowflake
Returns: Object - An object containing the deconstructed components of the snowflake:
- createdAt: The date and time when the snowflake was created.
- timestamp: The timestamp of the snowflake.
- workerId: The ID of the worker that generated the snowflake.
- processId: The ID of the process that generated the snowflake.
- increment: The increment portion of the snowflake.
- binary: The binary representation of the snowflake.
| Param | Type | Description |
|---|---|---|
| snowflake | string | The snowflake to deconstruct. |
Snowflake.generate([timestamp]) ⇒ string
Section titled “Snowflake.generate([timestamp]) ⇒ string”Generates a unique ID based on the given timestamp.
Kind: static method of Snowflake
Returns: string - - The generated unique ID.
Throws:
TypeError- If the timestamp is not a number or a valid Date object.
| Param | Type | Default | Description |
|---|---|---|---|
| [timestamp] | number | Date | Date.now() | The timestamp to generate the ID from. |