-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.d.ts
52 lines (48 loc) · 2.01 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Default length for the generated ID
export const DEFAULT_LENGTH: number;
// Default alphabet (set of characters) used for generating the ID
export const DEFAULT_ALPHABET: string;
/**
* Generates a unique ID with a specified length and custom alphabet.
*
* @param length (optional) - The length of the generated ID. Defaults to `DEFAULT_LENGTH` (8).
* @param customAlphabet (optional) - A custom set of characters to use for generating the ID. Defaults to `DEFAULT_ALPHABET`.
* @returns The generated ID as a string.
*
* @throws Error - Throws an error if length is less than 4.
*/
export function ssid(
length?: number,
customAlphabet?: string
): string;
/**
* Generates a unique ID with optional prefix and suffix, and a specified length and custom alphabet.
*
* @param length (optional) - The length of the generated ID. Defaults to `DEFAULT_LENGTH` (8).
* @param prefix (optional) - A string to prepend to the generated ID.
* @param suffix (optional) - A string to append to the generated ID.
* @param customAlphabet (optional) - A custom set of characters to use for generating the ID. Defaults to `DEFAULT_ALPHABET`.
* @returns The generated ID with affixes as a string.
*
* @throws Error - Throws an error if length is less than 4.
* @throws Error - Throws an error if neither `prefix` nor `suffix` is provided.
*/
export function ssidWithAffixes(
length?: number,
prefix?: string,
suffix?: string,
customAlphabet?: string
): string;
/**
* Generates a unique ID with timestamp and a short id with specified length and custom alphabet.
*
* @param length (optional) - The length of the generated ID. Defaults to `DEFAULT_LENGTH` (8).
* @param customAlphabet (optional) - A custom set of characters to use for generating the ID. Defaults to `DEFAULT_ALPHABET`.
* @returns The generated ID with timestamp and a short id as a string.
*
* @throws Error - Throws an error if length is less than 4.
*/
export function ssidWithTimestamp(
length?: number,
customAlphabet?: string
): string;