main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
983 bytes
|
Line | |
---|
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 | */
|
---|
13 | export function nanoid(size?: number): string
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Generate a unique ID based on a 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 defaultSize Size of the ID. The default size is 21.
|
---|
22 | * @returns A random string generator.
|
---|
23 | *
|
---|
24 | * ```js
|
---|
25 | * import { customAlphabet } from 'nanoid/non-secure'
|
---|
26 | * const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
---|
27 | * model.id = //=> "8ё56а"
|
---|
28 | * ```
|
---|
29 | */
|
---|
30 | export function customAlphabet(
|
---|
31 | alphabet: string,
|
---|
32 | defaultSize?: number
|
---|
33 | ): (size?: number) => string
|
---|
Note:
See
TracBrowser
for help on using the repository browser.