@sanely/words
v0.1.0
Published
Generate friendly, safe-for-work names from curated word lists
Maintainers
Readme
@sanely/words is a TypeScript package for friendly names. It returns names such as "amber-fox" for projects, usernames, labels, and demo data, with words drawn from curated, safe-for-work lists.
Features
generate()returns a random name, andcount()returns how many distinct names the same options allow.patternpicks the list for each word, such as["color", "animal"], and the type checker rejects a misspelled list name.listsadds custom word lists that a pattern can name.maxLengthlimits the length of the name, andomitexcludes words.randomtakes a seeded source of randomness, so a test can repeat a name.- Invalid options throw
InvalidOptionError, and options that no name satisfies throwNotEnoughWordsError. - No external dependencies.
Install
npm install @sanely/wordsThe package needs Node.js 20 or later.
Get started
import { count, generate } from "@sanely/words"
generate() // "amber-fox"
generate({ segments: 3, separator: "_" }) // "teal_heron_cathedral"
generate({ pattern: ["color", "animal"] }) // "teal-otter"
generate({ lists: { fruit: ["apple", "pear"] }, pattern: ["fruit", "animal"] }) // "pear-otter"
generate({ maxLength: 10 }) // "tan-heron"
count() // 1_084_149nDocumentation
Reference:
Contributing
Read the architecture, testing guide, and root contributor guide before changing the package.
Credits
The word lists start from joyful by Hayden Bleasel and Kaylee Williams, which builds on friendly-words by Glitch. They were filtered for safe, common words and extended with words from coolname, imsky/wordlists, moniker, random-word-slugs, and unique-names-generator.
License
MIT. See LICENSE, which includes the notices for the word lists.
