identigenium
Version:
Generate unique identifiers with configurable character sets and prefixes. Super tiny (tree-shakeable, base is 142 bytes, minified + bzipped)
29 lines (28 loc) • 1.46 kB
TypeScript
import type { IDSource } from '../identigenium.ts';
/**
* A configurable ID provider that generates unique identifiers using a specified character set,
* prefix, and starting counter value. This provider allows for customizable ID generation
* with support for resuming from a specific counter position.
*/
export declare class ConfigurableIDProvider implements IDSource {
#private;
idStream: Generator<string, string, void>;
/**
* Gets the number of already generated IDs.
* @returns The current counter value representing the number of IDs generated so far.
*/
get idCounter(): number;
/**
* Sets the number of already generated IDs. This allows resuming ID generation from a specific point.
* @param newCounterValue - The new counter value to set. Warning: Setting to less than current count risks duplicate ID generation.
*/
set idCounter(newCounterValue: number);
/**
* Creates a new ConfigurableIDProvider instance.
* @param permittedCharacters - A string containing all allowed characters for ID generation. MUST be a string of unique characters; this is not checked.
* @param startWithCounter - The initial counter value to start ID generation from (default: 0)
* @param prefix - An optional prefix to prepend to all generated IDs (default: "")
*/
constructor(permittedCharacters: string, startWithCounter?: number, prefix?: string);
generateID(): string;
}