mirror of
https://github.com/Wessel/Snowflakey.git
synced 2026-07-24 09:18:34 +02:00
Rewrite into TypeScript
This commit is contained in:
33
lib/types.ts
Normal file
33
lib/types.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export interface SnowflakeConfig {
|
||||
name?: string;
|
||||
async?: boolean;
|
||||
epoch?: number;
|
||||
workerId?: any,
|
||||
processId?: number,
|
||||
stringify?: boolean,
|
||||
workerBits: number,
|
||||
processBits: number,
|
||||
incrementBits: number
|
||||
}
|
||||
|
||||
export interface SnowflakeMutable {
|
||||
locks: any;
|
||||
locked: boolean;
|
||||
increment: any;
|
||||
lastTimestamp: number;
|
||||
}
|
||||
|
||||
export type Snowflake = number;
|
||||
|
||||
export interface SnowflakeWorker {
|
||||
options: SnowflakeConfig;
|
||||
workerId: number;
|
||||
_mutable: SnowflakeMutable;
|
||||
processId: number;
|
||||
_maxIncrement: number;
|
||||
_lock(): void;
|
||||
_unlock(): void;
|
||||
generate(): Snowflake;
|
||||
_generate(): Snowflake;
|
||||
_generateAsync(): Snowflake;
|
||||
}
|
||||
Reference in New Issue
Block a user