typedash
Version:
modern, type-safe collection of utility functions
28 lines (26 loc) • 761 B
text/typescript
/**
* Generates a unique identifier.
*
* If a `prefix` is provided, the resulting identifier will start with the prefix.
* @param prefix A prefix for the identifier.
* @returns A unique identifier.
* @example
* ```ts
* uniqueId('prefix-') // 'prefix-1q2w3e4r5t'
* ```
*/
declare function uniqueId<Prefix extends string>(prefix: Prefix): `${Prefix}${string}`;
/**
* Generates a unique identifier.
*
* If no `prefix` is provided, the resulting identifier will not have a prefix.
* @param prefix An optional prefix for the identifier.
* @returns A unique identifier.
* @example
* ```ts
* uniqueId() // '1q2w3e4r5t'
* uniqueId('prefix-') // 'prefix-1q2w3e4r5t'
* ```
*/
declare function uniqueId(prefix?: string): string;
export { uniqueId };