Gathering detailed insights and metrics for unique-username-generator
Gathering detailed insights and metrics for unique-username-generator
Gathering detailed insights and metrics for unique-username-generator
Gathering detailed insights and metrics for unique-username-generator
npm install unique-username-generator
99.7
Supply Chain
100
Quality
76.5
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
88 Stars
57 Commits
19 Forks
2 Watching
3 Branches
6 Contributors
Updated on 16 Nov 2024
Minified
Minified + Gzipped
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-1.5%
11,459
Compared to previous day
Last week
0.2%
75,840
Compared to previous week
Last month
36.5%
325,320
Compared to previous month
Last year
304.1%
1,408,076
Compared to previous year
A package to generate a unique username from email or randomly selected nouns and adjectives. User can add a separator between the username, define the maximum length of a username and adds up to six random digits.
1npm install unique-username-generator --save
1// Using Node.js `require()` 2const { generateFromEmail, generateUsername } = require("unique-username-generator"); 3// Using ES6 imports 4import { generateFromEmail, generateUsername } from "unique-username-generator";
It will generate username from email and add upto six random digits at the end of the name.
1// add three random digits 2const username = generateFromEmail( 3 "lakshmi.narayan@example.com", 4 3 5); 6console.log(username); // lakshminarayan234 7 8// add four random digits 9const username = generateFromEmail( 10 "lakshmi.narayan@example.com", 11 4 12); 13console.log(username); // lakshminarayan2347
It will generate unique username from adjectives, nouns, random digits and separator. You can control these following parameters - separator, number of random digits and maximum length of a username.
1// generaterUsername(separator, number of random digits, maximum length) 2 3// Without any parameter 4const username = generateUsername(); 5console.log(username); // blossomlogistical 6 7// With any separator like "-, _" 8const username = generateUsername("-"); 9console.log(username); // blossom-logistical 10 11// With random digits and no separator 12const username = generateUsername("", 3); 13console.log(username); // blossomlogistical732 14 15// With maximum length constraint and no separator, no random digits 16const username = generateUsername("", 0, 15); 17console.log(username); // blossomlogistic 18 19// With maximum length constraint and separator but no random digits 20const username = generateUsername("-", 0, 15); 21console.log(username); // blossom-logisti 22 23// With maximum length constraint and random digits but no separator 24const username = generateUsername("", 2, 19); 25console.log(username); // blossomlogistical73 26 27// With all parameters 28const username = generateUsername("-", 2, 20, 'unique username'); 29console.log(username); // unique-username-73
By default, the unique username generator library comes with 2 dictionaries out of the box, so that you can use them straight away.
The new syntax for using the default dictionaries is the following:
1import { uniqueUsernameGenerator, Config, adjectives, nouns } from 'unique-username-generator'; 2 3const config: Config = { 4 dictionaries: [adjectives, nouns] 5} 6 7const username: string = uniqueUsernameGenerator(config); // blossomlogistical
You might want to provide your custom dictionaries to use for generating your unique username, in order to meet your project requirements. You can easily do that using the dictionaries option.
1import { uniqueUsernameGenerator } from 'unique-username-generator'; 2 3const marvelCharacters = [ 4 'Iron Man', 5 'Doctor Strange', 6 'Hulk', 7 'Captain America', 8 'Thanos' 9]; 10 11const config: Config = { 12 dictionaries: [marvelCharacters], 13 separator: '', 14 style: 'capital', 15 randomDigits: 3 16} 17 18const username: string = uniqueUsernameGenerator(config); // Hulk123
Returns a string
with a random generated username
Type: Config
The options
argument mostly corresponds to the properties defined for uniqueUsernameGenerator. Only dictionaries
is required.
Option | Type | Description | Default value | Example value |
---|---|---|---|---|
dictionaries | array | This is an array of dictionaries. Each dictionary is an array of strings containing the words to use for generating the string. The provided dictionaries can be imported from the library as a separate modules and provided in the desired order. | n/a | import { uniqueUsernameGenerator, adjectives, nouns } from 'unique-username-generator'; const username: string = uniqueUsernameGenerator({ dictionaries: [nouns, adjectives]}); // blossomlogistical |
separator | string | A string separator to be used for separate the words generated. The default separator is set to be empty string. | "" | - |
randomDigits | number | A number of random digits to add at the end of a username. | 0 | 3 |
length | number | A maximum length of a username | 15 | 12 |
style | lowerCase | upperCase | capital | The 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 capital option will capitalize each word of the unique username generated | lowerCase | lowerCase |
The MIT License.
If you'd like to say thanks, I'd really appreciate a coffee :)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
security policy file detected
Details
Reason
Found 4/18 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More