UNPKG

nehoid

Version:

Advanced unique ID generation utility with multi-layer encoding, collision detection, and context-aware features

68 lines 2.63 kB
/** * Specialized ID generators for NehoID * Implements hierarchical, temporal, and sequential ID generation */ export declare class Specialized { /** * Generates a hierarchical ID with parent-child relationships * @param parent Optional parent ID to create a child under * @param level Hierarchy level (defaults to 1 if no parent, otherwise parent level + 1) * @param separator Character to separate hierarchy levels * @returns A hierarchical ID */ static hierarchical(options?: { parent?: string; level?: number; separator?: string; }): string; /** * Generates a time-ordered ID for chronological sorting * @param precision Time precision ('ms', 's', 'm', 'h', 'd') * @param suffix Whether to add a random suffix for uniqueness * @returns A temporal ID with timestamp */ static temporal(options?: { precision?: 'ms' | 's' | 'm' | 'h' | 'd'; suffix?: boolean; format?: 'hex' | 'dec' | 'b36'; }): string; /** * Generates a sequential ID suitable for database use * @param prefix Optional prefix for the ID * @param counter Current counter value * @param padLength Length to pad the counter to * @returns A sequential ID */ static sequential(options: { prefix?: string; counter: number; padLength?: number; suffix?: boolean; }): string; /** * Generates a temporal ID from a specific timestamp * @param timestamp Unix timestamp in milliseconds * @param precision Time precision ('ms', 's', 'm', 'h', 'd') * @param suffix Whether to add a random suffix for uniqueness * @param format Timestamp format ('hex' | 'dec' | 'b36') * @returns A temporal ID with the specified timestamp */ static fromTemporal(timestamp: number, options?: { precision?: 'ms' | 's' | 'm' | 'h' | 'd'; suffix?: boolean; format?: 'hex' | 'dec' | 'b36'; }): string; /** * Extracts timestamp from a temporal ID * @param temporalId The temporal ID to extract timestamp from * @param precision Time precision used in the temporal ID ('ms', 's', 'm', 'h', 'd') * @param format Timestamp format used in the temporal ID ('hex' | 'dec' | 'b36') * @returns Unix timestamp in milliseconds * @throws Error if the temporal ID format is invalid */ static fromTemporalToTimestamp(temporalId: string, options?: { precision?: 'ms' | 's' | 'm' | 'h' | 'd'; format?: 'hex' | 'dec' | 'b36'; }): number; } //# sourceMappingURL=specialized.d.ts.map