Skip to content
Myr

Document the alphabet bounds instead of guarding them at runtime (#609)

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

Per review: state in the custom-alphabet section that an alphabet must contain from 1 to 256 symbols, and that a generator built outside those bounds can loop forever instead of returning an ID.

authored by Jeff Lenamon · committed by GitHub · parent 07a39d6 · Browse files · 1 file+4 added−2 removed
This commit

State

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

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:README.md+4 added-2 removed
196 unmodified lines
197Check the safety of your custom alphabet and ID size in our198[ID collision probability] calculator. For more alphabets, check out the options199in [`nanoid-dictionary`].200201Alphabet must contain 256 symbols or less.202Otherwise, the security of the internal generator algorithm is not guaranteed.201Alphabet must contain from 1 to 256 symbols.202Otherwise, the security of the internal generator algorithm is not guaranteed,203and a generator built from an empty or over-256-symbol alphabet204can loop forever instead of returning an ID.205206In addition to setting a default size, you can change the ID size when calling207the function:208
237 unmodified lines