Identifier for human and machine
yarn add @sudoo/readable-identifier
# Or
npm install @sudoo/readable-identifier --save
You will need to install or create a word set before use this package.
For example:
yarn add @sudoo/words-english
# Or
npm install @sudoo/words-english --save
Generate readable pair/tuple for your uuid or other identifier
import { ReadableIdentifierGenerator } from "@sudoo/readable-identifier";
import { englishWords } from "@sudoo/words-english";
const identifier: string = "Your Awesome Identifier";
// Default
const generator = ReadableIdentifierGenerator.from(englishWords);
generator.generatePair(identifier); // worthless-lamb
generator.generateTuple(identifier); // oceanic-consist-france
// Override Connector
const generator = ReadableIdentifierGenerator.from(englishWords, {
join: ' ',
});
generator.generatePair(identifier); // worthless lamb
generator.generateTuple(identifier); // oceanic consist france
// Use Capital
const generator = ReadableIdentifierGenerator.from(englishWords, {
capital: true,
});
generator.generatePair(identifier); // Worthless-Lamb
generator.generateTuple(identifier); // Oceanic-Consist-France