UNPKG

930 BTypeScriptView Raw
1/**
2 * Generate URL-friendly unique ID. This method uses the non-secure
3 * predictable random generator with bigger collision probability.
4 *
5 * ```js
6 * import { nanoid } from 'nanoid/non-secure'
7 * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
8 * ```
9 *
10 * @param size Size of the ID. The default size is 21.
11 * @returns A random string.
12 */
13export function nanoid (size?: number): string
14
15/**
16 * Generate URL-friendly unique ID based on the custom alphabet.
17 * This method uses the non-secure predictable random generator
18 * with bigger collision probability.
19 *
20 * @param alphabet Alphabet used to generate the ID.
21 * @param size Size of the ID.
22 * @returns A random string.
23 *
24 * ```js
25 * import { customAlphabet } from 'nanoid/non-secure'
26 * const nanoid = customAlphabet('0123456789абвгдеё', 5)
27 * model.id = //=> "8ё56а"
28 * ```
29 */
30export function customAlphabet (alphabet: string, size: number): () => string
31
\No newline at end of file