UNPKG

@skorotkiewicz/snowflake-id

Version:

Snowflake ID is a unique identifier commonly used in distributed systems to generate unique IDs with a timestamp component. It is designed to ensure uniqueness, even in distributed and highly concurrent environments.

19 lines (17 loc) 484 B
declare class Snowflake { private machineId; private sequence; private lastTimestamp; private readonly timestampShift; private readonly machineIdShift; private readonly sequenceMask; constructor(machineId: number); generate(): Promise<string>; } interface DecodedSnowflake { timestamp: string; machineId: string; sequence: string; } declare function decodeSnowflake(idStr: string): DecodedSnowflake; export { Snowflake, decodeSnowflake };