import { Snowflake } from "https://deno.land/x/snowflakes@1.0.0/Snowflake.ts";
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(epoch: number | bigint | Date)Methods
deconstruct(id: string | bigint): DeconstructedSnowflake
Deconstructs a snowflake given a snowflake ID
generate(unnamed 0?: SnowflakeGenerateOptions)
Generates a snowflake given an epoch and optionally a timestamp
timestampFrom(id: string | bigint): number
Retrieves the timestamp field's value from a snowflake.