@squidcloud/client
Version:
A typescript implementation of the Squid client
35 lines (34 loc) • 1.29 kB
TypeScript
/** Generates a UUID-style ID. */
export declare function generateId(): string;
/** Default length if ID produced by `generateShortId`. */
export declare const DEFAULT_SHORT_ID_LENGTH = 18;
/**
* Generates an ID of the given `length` using lowercase latin letters and digits.
* If the 'prefix' provided replaces the first generated characters with the prefix.
*/
export declare function generateShortId(length?: number, prefix?: string): string;
/**
* Generates a set of unique IDs under the same behavior as `generateShortId`.
*
* @param length The length of the ID to be generated. Default is 18.
* @param prefix The prefix of the generated ID. Default is an empty string.
* @param count The number of IDs to be generated.
*/
export declare function generateShortIds({ count, length, prefix }: GenerateShortIdsOptions): string[];
/**
* Options for generating multiple short IDs.
*/
export interface GenerateShortIdsOptions {
/** The number of IDs to generate. */
count: number;
/**
* The length of each generated ID.
* @default DEFAULT_SHORT_ID_LENGTH.
*/
length?: number;
/**
* A string that must be a predefined prefix for each ID. Replaces the first generated characters.
* @default - no prefix.
*/
prefix?: string;
}