Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
928 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 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 | */
|
---|
| 30 | export function customAlphabet(alphabet: string, size: number): () => string
|
---|
Note:
See
TracBrowser
for help on using the repository browser.