/nanoid-dictionary

Predefined character sets to use with nanoid

Primary LanguageJavaScriptMIT LicenseMIT

nanoid-dictionary

Predefined character sets to use with nanoid. Used by nanoid-generate.

npm

Usage

Install nanoid and dictionary

npm i nanoid nanoid-dictionary

Require a generator and pass a string from the dictionary

const generate = require('nanoid/generate');
const dictionary = require('nanoid-dictionary');

const lowercaseRandomString = generate(dictionary.lowercase, 10);

Or instead you can require a specific dictionary

const generate = require('nanoid/generate');
const englishLowercase = require('nanoid-dictionary/lowercase');

const lowercaseRandomString = generate(englishLowercase, 10);

Character sets

numbers

Numbers from 0 to 9

const numbers = require('nanoid-dictionary/numbers');

lowercase

Lowercase English letters.

Available both as alphabets.lowercase and simply lowercase.

const englishLowercase = require('nanoid-dictionary/lowercase');

uppercase

Uppercase English letters.

Available both as alphabets.uppercase and simply uppercase.

const englishUppercase = require('nanoid-dictionary/uppercase');

nolookalikes

Numbers and english alphabet without lookalikes: 1, l, I, 0, O, o, u, v, 5, S, s, 2, Z.

const nolookalikes = require('nanoid-dictionary/nolookalikes');

nolookalikes-safe

Same as noolookalikes but with removed vowels and following letters: 3, 4, x, X, V.

This list should protect you from accidentally getting obscene words in generated strings.

const nolookalikesSafe = require('nanoid-dictionary/nolookalikes-safe');