Skip to content
Myr

Add non-secure/generate

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent b3fa096 · Browse files · 4 files+70 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+70 added−1 removed

  • tests:+32 added−0 removed
  • other:+38 added−1 removed

4 files+70 added−1 removed

added:non-secure/generate.js+27 added
added:test/non-secure-generate.test.js+32 added
modified:package.json+4 added
73 unmodified lines
74 "path": "non-secure/index.js",75 "limit": "105 B"76 },77 {78 "path": "non-secure/generate.js",79 "limit": "47 B"80 },81 {82 "path": "async/index.js",83 "limit": "153 B"84 },85 {
101 unmodified lines
modified:README.md+7 added-1 removed
193 unmodified lines
194195Alphabet must contain 256 symbols or less.196Otherwise, the generator will not be secure.197198Asynchronous API is also available:198Asynchronous and non-secure API is also available:199200```js201const generate = require('nanoid/async/generate')202async function createUser () {203 user.id = await generate('1234567890abcdef', 10)204}205```206207```js208const generate = require('nanoid/non-secure/generate')209210user.id = generate('1234567890abcdef', 10)211```212213[ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/214[`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary215216
79 unmodified lines