npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

mngen

1.1.0 • Public • Published

mnGen - Mnemonic Word Generator

Spits out random words from this word list.

The word list consists of 1633 words that are easy to read, say, understand and remember. They are also easy to distinguish from one another.

"... suitable for transmission or storage by voice, handwriting, memorization or other non-computerized means."

You could use it to generate easy-to-remember passwords or name your servers. Or dogs. Sometimes you just need a few top-notch words thrown at you.

Install

$ npm install --save mngen

Usage

 
var mnGen = require('mngen');
 
mnGen.word();     // => 'tokyo'
mnGen.word(3);    // => "office-piano-fabric"
 
mnGen.list(3);    // => ['canoe', 'amigo', 'kermit']
mnGen.list(3, 2); // => ['fuji-visa', 'kilo-lemon', 'baker-echo']
mnGen.list(3, 2, '/'); // => ['fuji/visa', 'kilo/lemon', 'baker/echo']
 
mngen.list(2665057, 2); // => ERR: Max list length for [glue] === 2 is 2665056

API

.word([[glue], [separator]])

Returns: String

  • Get a single random word
  • Give an integer glue to make it a dash-joined combo of multiple words.
  • Specify separator to customize separator between combos of multiple words.
mnGen.word();  // => "eagle"
mnGen.word(3); // => "office-piano-fabric"
mnGen.word(3, '/'); // => "office/piano/fabric"

.list([length, [glue], [separator]])

Returns: Array

  • Get an array of random words.
  • Default length is 100
  • Array entries are unique.
  • Specify glue to make entries dash-joined combos of multiple words.
  • Specify separator to customize separator between combos of multiple words.
  • Throws error if length > possible unique entries given glue (See Usage for example)
nmGen.list();     // => An array of 100 unique words
mnGen.list(3);    // => ['canoe', 'amigo', 'kermit']
mnGen.list(3, 2); // => ['fuji-visa', 'kilo-lemon', 'baker-echo']
mnGen.list(3, 2, '/'); // => ['fuji/visa', 'kilo/lemon', 'baker/echo']

CLI

$ npm install --global mngen

$ mngen
# => tokyo 
 
$ mngen --glue 2
# => "english-legal" 
 
$ mngen --glue 2 --separator /
# => "dexter/toronto" 
 
$ mngen --list 3
# => canoe amigo kermit 
 
$ mngen --list 2 --glue 3
# => oxford-soviet-rubber shave-deal-freddie 
 

TODO

  • Add options:
    • Choose entry separator for list in cli (comma, newline, space, etc)
    • Custom word-lists

Thanks

Inspired by Sindre Sorhus

install

npm i mngen

Downloadsweekly downloads

5,754

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability