Skip to content
Myr

index.d.ts

This file

Path

non-secure/index.d.ts

48 lines · 1.5 KiB · TypeScript

Last changed by

Move module docs to .d.tsAndrey Sitnikbefore adoptiond4fb377

History of this file

Take it

The walk stopped after 200 commits: lines older than cdc3edc point at it.

Update size limitAndrey Sitnikbefore adoptioncdc3edc

line 1why, one step back
1/**

Move module docs to .d.tsAndrey Sitnikbefore adoptiond4fb377

lines 2–14why, one step back
2 * By default, Nano ID uses hardware random bytes generation for security
3 * and low collision probability. If you are not so concerned with security,4 * you can use it for environments without hardware random generators.5 *6 * ```js7 * import { nanoid } from 'nanoid/non-secure'8 * const id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"9 * ```10 *11 * @module12 */1314/**

Update size limitAndrey Sitnikbefore adoptioncdc3edc

lines 15–23why, one step back
15 * Generate URL-friendly unique ID. This method uses the non-secure
16 * predictable random generator with bigger collision probability.17 *18 * ```js19 * import { nanoid } from 'nanoid/non-secure'20 * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"21 * ```22 *23 * @param size Size of the ID. The default size is 21.

Add opaque type for non-secure generatorAndrey Sitnikbefore adoption1e24963

line 24why, one step back
24 * @typeparam Type The ID type to replace `string` with some opaque type.

Update size limitAndrey Sitnikbefore adoptioncdc3edc

lines 25–26why, one step back
25 * @returns A random string.
26 */

Add opaque type for non-secure generatorAndrey Sitnikbefore adoption1e24963

line 27why, one step back
27export function nanoid<Type extends string>(size?: number): Type

Update size limitAndrey Sitnikbefore adoptioncdc3edc

lines 28–35why, one step back
28
29/**30 * Generate a unique ID based on a custom alphabet.31 * This method uses the non-secure predictable random generator32 * with bigger collision probability.33 *34 * @param alphabet Alphabet used to generate the ID.35 * @param defaultSize Size of the ID. The default size is 21.

Add opaque type for non-secure generatorAndrey Sitnikbefore adoption1e24963

line 36why, one step back
36 * @typeparam Type The ID type to replace `string` with some opaque type.

Update size limitAndrey Sitnikbefore adoptioncdc3edc

lines 37–41why, one step back
37 * @returns A random string generator.
38 *39 * ```js40 * import { customAlphabet } from 'nanoid/non-secure'41 * const nanoid = customAlphabet('0123456789абвгдеё', 5)

Add opaque type for non-secure generatorAndrey Sitnikbefore adoption1e24963

line 42why, one step back
42 * model.id = nanoid() //=> "8ё56а"

Update size limitAndrey Sitnikbefore adoptioncdc3edc

lines 43–44why, one step back
43 * ```
44 */

Add opaque type for non-secure generatorAndrey Sitnikbefore adoption1e24963

line 45why, one step back
45export function customAlphabet<Type extends string>(

Update size limitAndrey Sitnikbefore adoptioncdc3edc

lines 46–47why, one step back
46 alphabet: string,
47 defaultSize?: number

Add opaque type for non-secure generatorAndrey Sitnikbefore adoption1e24963

line 48why, one step back
48): (size?: number) => Type