1.0.0 • Published 9 months ago

@siantech/username-generator v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@siantech/username-generator

npm version install size npm downloads NPM

Installing

Using npm:

$ npm install @siantech/username-generator --save

Once the package is installed, you can import the library using import or require approach:

  • Importing
// Using Node.js `require()`
const { UsernameGenerator } = require("@siantech/username-generator");
// Using ES6 imports
import { UsernameGenerator } from "@siantech/username-generator";

Usage

Generate username from email

It will generate username from email and add four random digits at the end of the name.

const generator = new UsernameGenerator();
const username = generator.generateFromEmail(
  "john.smith@example.com"
);
console.log(username); // JohnsmithRedPotato3762 🏋️

Randomly generate unique username.

It will generate unique username from names, mythical creatures, colors and nouns digits and separator. You can control these following parameters - separator and emoji.

// generate username using the default configuration
const generator = new UsernameGenerator();
const username = generator.generate();
console.log(username); // IsabelleGrayDjinn7514

// generate username using separator and emoji
const config = {
    separator: "*",
    showEmoji: true
}
const generator = new UsernameGenerator(config);
const username = generator.generate();
console.log(username); // Christopher*Gray*Griffin*2757 👆

options

Type: Config

The options argument mostly corresponds to the properties defined for uniqueUsernameGenerator. Only dictionaries is required.

OptionTypeDescriptionDefault valueExample value
dictionarycreatures \| nouns \| fruits-and-vegetablesBy default, the username is generated using Name + Colour + Mythical Creatures dictionaries. You can change Mythical Creatures and use another dictionary like "nouns" or "fruits-and-vegetables".creaturesnouns
separatorstringA string separator to be used for separate the words generated. The default separator is set to be empty string.""-
emojibooleanIf set to true, it will display a random emoji at the end of the generated Username.falsetrue
stylelowerCase \| upperCase \| camelThe default value is set to lowerCase and it will return a lower case username.By setting the value to upperCase, the words, will be returned with all the letters in upper case format.The camel option will capitalize each word of the unique username generatedlowerCaselowerCase

License

The MIT License.

Thank you

If you'd like to say thanks, I'd really appreciate a coffee :)