nanoid 5.0.9 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +8 -5
- package/package.json +1 -1
package/index.d.ts
CHANGED
@@ -10,9 +10,10 @@
|
|
10
10
|
* ```
|
11
11
|
*
|
12
12
|
* @param size Size of the ID. The default size is 21.
|
13
|
+
* @typeparam Type The type of the generated ID.
|
13
14
|
* @returns A random string.
|
14
15
|
*/
|
15
|
-
export function nanoid(size?: number):
|
16
|
+
export function nanoid<Type extends string>(size?: number): Type
|
16
17
|
|
17
18
|
/**
|
18
19
|
* Generate secure unique ID with custom alphabet.
|
@@ -22,6 +23,7 @@ export function nanoid(size?: number): string
|
|
22
23
|
*
|
23
24
|
* @param alphabet Alphabet used to generate the ID.
|
24
25
|
* @param defaultSize Size of the ID. The default size is 21.
|
26
|
+
* @typeparam Type The type of the generated ID.
|
25
27
|
* @returns A random string generator.
|
26
28
|
*
|
27
29
|
* ```js
|
@@ -30,10 +32,10 @@ export function nanoid(size?: number): string
|
|
30
32
|
* nanoid() //=> "8ё56а"
|
31
33
|
* ```
|
32
34
|
*/
|
33
|
-
export function customAlphabet(
|
35
|
+
export function customAlphabet<Type extends string>(
|
34
36
|
alphabet: string,
|
35
37
|
defaultSize?: number
|
36
|
-
): (size?: number) =>
|
38
|
+
): (size?: number) => Type
|
37
39
|
|
38
40
|
/**
|
39
41
|
* Generate unique ID with custom random generator and alphabet.
|
@@ -58,13 +60,14 @@ export function customAlphabet(
|
|
58
60
|
* @param alphabet Alphabet used to generate a random string.
|
59
61
|
* @param size Size of the random string.
|
60
62
|
* @param random A random bytes generator.
|
63
|
+
* @typeparam Type The type of the generated ID.
|
61
64
|
* @returns A random string generator.
|
62
65
|
*/
|
63
|
-
export function customRandom(
|
66
|
+
export function customRandom<Type extends string>(
|
64
67
|
alphabet: string,
|
65
68
|
size: number,
|
66
69
|
random: (bytes: number) => Uint8Array
|
67
|
-
): () =>
|
70
|
+
): () => Type
|
68
71
|
|
69
72
|
/**
|
70
73
|
* URL safe symbols.
|