source: imaps-frontend/node_modules/nanoid/async/index.d.ts

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * Generate secure URL-friendly unique ID. The non-blocking version.
3 *
4 * By default, the ID will have 21 symbols to have a collision probability
5 * similar to UUID v4.
6 *
7 * ```js
8 * import { nanoid } from 'nanoid/async'
9 * nanoid().then(id => {
10 * model.id = id
11 * })
12 * ```
13 *
14 * @param size Size of the ID. The default size is 21.
15 * @returns A promise with a random string.
16 */
17export function nanoid(size?: number): Promise<string>
18
19/**
20 * A low-level function.
21 * Generate secure unique ID with custom alphabet. The non-blocking version.
22 *
23 * Alphabet must contain 256 symbols or less. Otherwise, the generator
24 * will not be secure.
25 *
26 * @param alphabet Alphabet used to generate the ID.
27 * @param defaultSize Size of the ID. The default size is 21.
28 * @returns A function that returns a promise with a random string.
29 *
30 * ```js
31 * import { customAlphabet } from 'nanoid/async'
32 * const nanoid = customAlphabet('0123456789абвгдеё', 5)
33 * nanoid().then(id => {
34 * model.id = id //=> "8ё56а"
35 * })
36 * ```
37 */
38export function customAlphabet(
39 alphabet: string,
40 defaultSize?: number
41): (size?: number) => Promise<string>
42
43/**
44 * Generate an array of random bytes collected from hardware noise.
45 *
46 * ```js
47 * import { random } from 'nanoid/async'
48 * random(5).then(bytes => {
49 * bytes //=> [10, 67, 212, 67, 89]
50 * })
51 * ```
52 *
53 * @param bytes Size of the array.
54 * @returns A promise with a random bytes array.
55 */
56export function random(bytes: number): Promise<Uint8Array>
Note: See TracBrowser for help on using the repository browser.