Letter-id is a group of small functions to create letter based random strings.
Use the package manager yarn
or npm
to install letter-id.
yarn add letter-id
or
npm i letter-id
import { generateLetterId } from 'letter-id'
const id = generateLetterId()
// yay-lay-lom
Creates custom strings with your preferences.
import { generateCustomLetterId } from 'letter-id'
const id = generateCustomLetterId(2, 5, '*')
// heyla*hooop
name | type | default | description |
---|---|---|---|
block | int | 3 | number of blocks separated by the custom/default separator |
numberOfEl | int | 3 | number of letters in a block |
separator | string | - | block separator |
Creates a string group from either a default 4 letter English word list, or a provided list, separated by default/custom separator.
import { generateWordId } from 'letter-id'
const id = generateWordId(3)
// cool-wool-loop
name | type | default | description |
---|---|---|---|
block | int | 3 | number of blocks separated by the custom/default separator |
separator | string | - | block separator |
wordList | string Array | DefaultList | 4 letter english words from FreeDictionary |
Creates a string starting with the provided string.
import { generateIdStartingWith } from 'letter-id'
const id = generateCustomLetterId('hello-world')
// hello-world-nah
name | type | default | description |
---|---|---|---|
startWith | string | provided string to start the return value | |
block | int | 1 | number of blocks separated by the custom/default separator |
separator | string | - | block separator |
numberOfEl | int | 3 | number of letters in a block |
If you are planning to use letter-id
as a unique identifier, you need to be sure that generated keys are not repeated. The uniqueness of the keys can not be guaranteed.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.