snowflake-uuid
Version:
Twitter's Snowflake generator implementation for NodeJS
21 lines (20 loc) • 586 B
TypeScript
declare type Snowflake = bigint | number;
interface WorkerOptions {
epoch?: Snowflake;
workerIdBits?: Snowflake;
datacenterIdBits?: Snowflake;
sequence?: Snowflake;
sequenceBits?: Snowflake;
}
export declare class Worker {
#private;
constructor(workerId?: Snowflake, datacenterId?: Snowflake, options?: WorkerOptions);
get workerId(): bigint;
get datacenterId(): bigint;
get currentSequence(): bigint;
get lastTimestamp(): bigint;
nextId(): bigint;
tilNextMillis(lastTimestamp: bigint): bigint;
static now(): bigint;
}
export {};