{"id":28192740,"url":"https://github.com/subhamg/unique-username-generator","last_synced_at":"2025-05-16T12:15:20.737Z","repository":{"id":40558458,"uuid":"369879191","full_name":"subhamg/unique-username-generator","owner":"subhamg","description":"A package to generate a unique username from email or randomly selected nouns and adjectives. Developer can add a separator between the username, define the maximum length of a username and adds up to six random digits.","archived":false,"fork":false,"pushed_at":"2025-05-12T08:04:49.000Z","size":378,"stargazers_count":98,"open_issues_count":6,"forks_count":22,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T09:34:06.840Z","etag":null,"topics":["javascript","nodejs","npm","npm-package","random-username","typescript","unique-username-generator","username-generator"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/unique-username-generator","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/subhamg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-22T18:24:33.000Z","updated_at":"2025-05-12T08:04:46.000Z","dependencies_parsed_at":"2024-01-12T11:50:57.793Z","dependency_job_id":"39f0c7b0-d7b9-456d-a70d-fd24757555b2","html_url":"https://github.com/subhamg/unique-username-generator","commit_stats":{"total_commits":47,"total_committers":7,"mean_commits":6.714285714285714,"dds":0.276595744680851,"last_synced_commit":"885efc123d10bef59874d936774933e87796cdb9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhamg%2Funique-username-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhamg%2Funique-username-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhamg%2Funique-username-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhamg%2Funique-username-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subhamg","download_url":"https://codeload.github.com/subhamg/unique-username-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254527111,"owners_count":22085920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","npm","npm-package","random-username","typescript","unique-username-generator","username-generator"],"created_at":"2025-05-16T12:15:15.695Z","updated_at":"2025-05-16T12:15:20.715Z","avatar_url":"https://github.com/subhamg.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/subhamg"],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/npm/v/unique-username-generator.svg)](https://npmjs.org/package/unique-username-generator)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/subhamg/unique-username-generator.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/subhamg/unique-username-generator/alerts/)\n[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/subhamg/unique-username-generator.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/subhamg/unique-username-generator/context:javascript)\n![npm](https://img.shields.io/npm/dt/unique-username-generator)\n![NPM](https://img.shields.io/npm/l/unique-username-generator)\n\n[![visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fsubhamg%2Funique-username-generator\u0026countColor=%232ccce4\u0026style=flat)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fsubhamg%2Funique-username-generator)\n\u003cspan class=\"badge-buymeacoffee\"\u003e\n\u003ca href=\"https://www.buymeacoffee.com/subhamg\" title=\"Donate to this project using Buy Me A Coffee\"\u003e\u003cimg src=\"https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg\" alt=\"Buy Me A Coffee donate button\" /\u003e\u003c/a\u003e\n\u003c/span\u003e\n\n# unique-username-generator\n\nA 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.\n\n[![NPM](https://nodei.co/npm/unique-username-generator.png)](https://nodei.co/npm/unique-username-generator/)\n\n## Installation\n\n```javascript\nnpm install unique-username-generator --save\n```\n\n- Importing\n\n```javascript\n// Using Node.js `require()`\nconst { generateFromEmail, generateUsername } = require(\"unique-username-generator\");\n// Using ES6 imports\nimport { generateFromEmail, generateUsername } from \"unique-username-generator\";\n```\n\n## Usage\n\n### Generate username from email\n\nIt will generate username from email and add upto six random digits at the end of the name.\n\n```javascript\n// add three random digits\nconst username = generateFromEmail(\n  \"lakshmi.narayan@example.com\",\n  3\n);\nconsole.log(username); // lakshminarayan234\n\n// add four random digits\nconst username = generateFromEmail(\n  \"lakshmi.narayan@example.com\",\n  4\n);\nconsole.log(username); // lakshminarayan2347\n```\n\n### Randomly generate unique username.\n\nIt 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.\n\n```javascript\n// generaterUsername(separator, number of random digits, maximum length)\n\n// Without any parameter\nconst username = generateUsername();\nconsole.log(username); // blossomlogistical\n\n// With any separator like \"-, _\"\nconst username = generateUsername(\"-\");\nconsole.log(username); // blossom-logistical\n\n// With random digits and no separator\nconst username = generateUsername(\"\", 3);\nconsole.log(username); // blossomlogistical732\n\n// With maximum length constraint and no separator, no random digits\nconst username = generateUsername(\"\", 0, 15);\nconsole.log(username); // blossomlogistic\n\n// With maximum length constraint and separator but no random digits\nconst username = generateUsername(\"-\", 0, 15);\nconsole.log(username); // blossom-logisti\n\n// With maximum length constraint and random digits but no separator\nconst username = generateUsername(\"\", 2, 19);\nconsole.log(username); // blossomlogistical73\n\n// With all parameters\nconst username = generateUsername(\"-\", 2, 20, 'unique username');\nconsole.log(username); // unique-username-73\n```\n\n### Default dictionaries\n\nBy default, the unique username generator library comes with 2 dictionaries out of the box, so that you can use them straight away.\n\nThe new syntax for using the default dictionaries is the following:\n\n```javascript\nimport { uniqueUsernameGenerator, Config, adjectives, nouns } from 'unique-username-generator';\n\nconst config: Config = {\n  dictionaries: [adjectives, nouns]\n}\n\nconst username: string = uniqueUsernameGenerator(config); // blossomlogistical\n```\n\n### Custom dictionaries\n\nYou 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.\n\n```javascript\nimport { uniqueUsernameGenerator } from 'unique-username-generator';\n\nconst marvelCharacters = [\n  'Iron Man',\n  'Doctor Strange',\n  'Hulk',\n  'Captain America',\n  'Thanos'\n];\n\nconst config: Config = {\n  dictionaries: [marvelCharacters],\n  separator: '',\n  style: 'capital',\n  randomDigits: 3\n}\n\nconst username: string = uniqueUsernameGenerator(config); // Hulk123\n```\n\n## API\n\n### uniqueUsernameGenerator (options)\nReturns a `string` with a random generated username\n\n### options\n\nType: `Config`\n\nThe `options` argument mostly corresponds to the properties defined for uniqueUsernameGenerator. Only `dictionaries` is required.\n\n\n| Option       | Type                                | Description                                                                                                                                                                                                                                                                         | Default value | Example value                                                                                                                                                                                                           |\n|--------------|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| dictionaries | `array`                             | This is an array of dictionaries. Each dictionary is an array of strings containing the words to use for generating the string.\u003cbr\u003eThe provided dictionaries can be imported from the library as a separate modules and provided in the desired order.                              | n/a           | \u003cbr\u003e```import { uniqueUsernameGenerator, adjectives, nouns } from 'unique-username-generator';```\u003cbr\u003e```const username: string = uniqueUsernameGenerator({ dictionaries: [nouns, adjectives]}); // blossomlogistical``` |\n| separator    | `string`                            | A string separator to be used for separate the words generated. The default separator is set to be empty string.                                                                                                                                                                    | \"\"            | `-`                                                                                                                                                                                                                     |\n| randomDigits | `number`                            | A number of random digits to add at the end of a username.                                                                                                                                                                                                                          | 0             | `3`                                                                                                                                                                                                                     |\n| length       | `number`                            | A maximum length of a username                                                                                                                                                                                                                                                      | 15            | `12`                                                                                                                                                                                                                    |\n| style        | `lowerCase \\| upperCase \\| capital` | The default value is set to `lowerCase` and it will return a lower case username.\u003cbr\u003eBy setting the value to `upperCase`, the words, will be returned with all the letters in upper case format.\u003cbr\u003eThe `capital` option will capitalize each word of the unique username generated | lowerCase     | `lowerCase`                                                                                                                                                                                                             |\n\n## License\n\nThe MIT License.\n\n## Thank you\nIf you'd like to say thanks, I'd really appreciate a coffee :)\n\n\u003ca href=\"https://www.buymeacoffee.com/subhamg\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 50px !important;width: 200px !important;\" \u003e\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhamg%2Funique-username-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubhamg%2Funique-username-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhamg%2Funique-username-generator/lists"}