From c7f4219df85fa3be9adfdd3486ebfa8a82739e09 Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Mon, 14 Feb 2022 21:45:06 +0100 Subject: [PATCH] Sync English and Russian docs --- README.md | 30 ++++++++++++++---------------- README.ru.md | 9 +++++++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d95e8b42..9899df8b 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,20 @@ const nanoid = customAlphabet('1234567890abcdef', 10) model.id = nanoid() //=> "4f90d13a42" ``` +```js +import { customAlphabet } from 'nanoid/async' +const nanoid = customAlphabet('1234567890abcdef', 10) +async function createUser () { + user.id = await nanoid() +} +``` + +```js +import { customAlphabet } from 'nanoid/non-secure' +const nanoid = customAlphabet('1234567890abcdef', 10) +user.id = nanoid() +``` + Check the safety of your custom alphabet and ID size in our [ID collision probability] calculator. For more alphabets, check out the options in [`nanoid-dictionary`]. @@ -268,22 +282,6 @@ const nanoid = customAlphabet('1234567890abcdef', 10) model.id = nanoid(5) //=> "f01a2" ``` -Customizable asynchronous and non-secure APIs are also available: - -```js -import { customAlphabet } from 'nanoid/async' -const nanoid = customAlphabet('1234567890abcdef', 10) -async function createUser () { - user.id = await nanoid() -} -``` - -```js -import { customAlphabet } from 'nanoid/non-secure' -const nanoid = customAlphabet('1234567890abcdef', 10) -user.id = nanoid() -``` - [ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/ [`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary diff --git a/README.ru.md b/README.ru.md index be3208e1..72e99c2f 100644 --- a/README.ru.md +++ b/README.ru.md @@ -284,6 +284,15 @@ user.id = nanoid() Алфавит должен содержать ≤256 символов. Иначе мы не сможем гарантировать непредсказуемость ID. +Длину ID можно менять не только в `customAlphabet()`, но и при вызове +генератора, который она вернёт: + +```js +import { customAlphabet } from 'nanoid' +const nanoid = customAlphabet('1234567890abcdef', 10) +model.id = nanoid(5) //=> "f01a2" +``` + [на нашем калькуляторе]: https://alex7kom.github.io/nano-nanoid-cc/ [`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary