{"_id":"@alixmixx/unique-username-generator","_rev":"2-5792ae29bbcbcd5dbbe8d1d0417c202e","name":"@alixmixx/unique-username-generator","dist-tags":{"latest":"1.1.7"},"versions":{"1.1.5":{"name":"@alixmixx/unique-username-generator","version":"1.1.5","keywords":["generate","username","username-from-email","email","generate username","generate-username-from-email","generate unique username","generate-unique-username","generate-unique-name","@alixmixx/unique-username-generator","unique-name-generator","unique","random","user","generator","node"],"author":{"name":"Alixmixx"},"license":"MIT","_id":"@alixmixx/unique-username-generator@1.1.5","maintainers":[{"name":"alixmixx","email":"alixmuller.am@gmail.com"}],"homepage":"https://github.com/Alixmixx/unique-username-generator#readme","bugs":{"url":"https://github.com/Alixmixx/unique-username-generator/issues"},"dist":{"shasum":"3b426ba3cb6308b386422875daf5abecb9588cb8","tarball":"https://registry.npmjs.org/@alixmixx/unique-username-generator/-/unique-username-generator-1.1.5.tgz","fileCount":11,"integrity":"sha512-HqyLBIwsUin4ynpHZuijNv966J1vMhxvGeCNvZVJnj6RY+HcLIM1sxhl+A4A+tyqv3xl6X1mlVAKmZoqj7+SeA==","signatures":[{"sig":"MEQCIAikEeCAgat1rQaq5TddqqgdCxuqHJqJx2+WTnZOFH1NAiBdlH2WKtgr/EkhnMbyKB70CPsYQK0D3+ovE68ie5QREg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":244584},"main":"./dist/index.js","types":"./dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"3e124d5e750f829b0886d291a04b19c057a46052","scripts":{"lint":"eslint '*/**/*.ts'","test":"ts-mocha tests/**/*.test.ts","build":"tsc","prepare":"npm run build","coverage":"nyc npm test && npm run cover:report","cover:report":"nyc report --reporter=lcov --reporter=text","semantic-release":"semantic-release --branches main"},"_npmUser":{"name":"alixmixx","email":"alixmuller.am@gmail.com"},"repository":{"url":"git+https://github.com/Alixmixx/unique-username-generator.git","type":"git"},"_npmVersion":"10.9.0","description":"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.","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.6","mocha":"^10.0.0","eslint":"^8.15.0","ts-node":"^10.9.1","ts-mocha":"^10.0.0","typescript":"^4.6.4","@types/chai":"^4.3.1","@types/node":"^17.0.33","@types/mocha":"^9.1.1","semantic-release":"^19.0.5","source-map-support":"^0.5.21","@typescript-eslint/parser":"^5.23.0","cz-conventional-changelog":"^3.3.0","@typescript-eslint/eslint-plugin":"^5.23.0","@istanbuljs/nyc-config-typescript":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/unique-username-generator_1.1.5_1742004154345_0.40291477219824645","host":"s3://npm-registry-packages-npm-production"}},"1.1.7":{"name":"@alixmixx/unique-username-generator","version":"1.1.7","description":"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.","main":"./dist/index.js","scripts":{"build":"tsc","test":"ts-mocha tests/**/*.test.ts","coverage":"nyc npm test && npm run cover:report","cover:report":"nyc report --reporter=lcov --reporter=text","lint":"eslint '*/**/*.ts'","prepare":"npm run build","semantic-release":"semantic-release --branches main"},"repository":{"type":"git","url":"git+https://github.com/Alixmixx/unique-username-generator.git"},"keywords":["generate","username","username-from-email","email","generate username","generate-username-from-email","generate unique username","generate-unique-username","generate-unique-name","@alixmixx/unique-username-generator","unique-name-generator","unique","random","user","generator","node"],"author":{"name":"Alixmixx"},"license":"MIT","bugs":{"url":"https://github.com/Alixmixx/unique-username-generator/issues"},"homepage":"https://github.com/Alixmixx/unique-username-generator#readme","devDependencies":{"@istanbuljs/nyc-config-typescript":"^1.0.2","@types/chai":"^4.3.1","@types/mocha":"^9.1.1","@types/node":"^17.0.33","@typescript-eslint/eslint-plugin":"^5.23.0","@typescript-eslint/parser":"^5.23.0","chai":"^4.3.6","cz-conventional-changelog":"^3.3.0","eslint":"^8.15.0","mocha":"^10.0.0","nyc":"^15.1.0","semantic-release":"^19.0.5","source-map-supclearport":"^0.5.21","ts-mocha":"^10.0.0","ts-node":"^10.9.1","typescript":"^4.6.4"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"types":"./dist/index.d.ts","gitHead":"0238c94e8eeec41f6ec1ea10b858d79e0a95fab0","_id":"@alixmixx/unique-username-generator@1.1.7","_nodeVersion":"22.12.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-9uyflFa5Kh548ZEEkz0oR8WRo2UDgeMkk3t5RKsrTY/8SW4T0M+YFN9z2dwcWqmbjngjMSHTjJjdYGRtLVs5EA==","shasum":"111b987360d744bc1c83183c38b7e89c601c4b55","tarball":"https://registry.npmjs.org/@alixmixx/unique-username-generator/-/unique-username-generator-1.1.7.tgz","fileCount":11,"unpackedSize":244999,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIETcPOgzd+sup7W9fvA7Bj62W8B4mfK/3dXDImyUCCm3AiEAvfVNoKWiSj6xB2LmQWYpwiFUol5FioQoCh5/jvHEvUU="}]},"_npmUser":{"name":"alixmixx","email":"alixmuller.am@gmail.com"},"directories":{},"maintainers":[{"name":"alixmixx","email":"alixmuller.am@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unique-username-generator_1.1.7_1742005053337_0.38560664728219574"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-15T02:02:34.222Z","modified":"2025-03-15T02:17:33.704Z","1.1.5":"2025-03-15T02:02:34.602Z","1.1.7":"2025-03-15T02:17:33.524Z"},"bugs":{"url":"https://github.com/Alixmixx/unique-username-generator/issues"},"author":{"name":"Alixmixx"},"license":"MIT","homepage":"https://github.com/Alixmixx/unique-username-generator#readme","keywords":["generate","username","username-from-email","email","generate username","generate-username-from-email","generate unique username","generate-unique-username","generate-unique-name","@alixmixx/unique-username-generator","unique-name-generator","unique","random","user","generator","node"],"repository":{"type":"git","url":"git+https://github.com/Alixmixx/unique-username-generator.git"},"description":"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.","maintainers":[{"name":"alixmixx","email":"alixmuller.am@gmail.com"}],"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&logoWidth=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&logoWidth=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&countColor=%232ccce4&style=flat)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fsubhamg%2Funique-username-generator)\n<span class=\"badge-buymeacoffee\">\n<a href=\"https://www.buymeacoffee.com/subhamg\" title=\"Donate to this project using Buy Me A Coffee\"><img src=\"https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg\" alt=\"Buy Me A Coffee donate button\" /></a>\n</span>\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 @alixmixx/unique-username-generator\n```\n\n```javascript\nyarn add @alixmixx/unique-username-generator\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// With style formatting\nconst username = generateUsername(\"-\", 0, undefined, undefined, Style.CamelCase);\nconsole.log(username); // blossomLogistical\n\n// With style formatting\nconst username = generateUsername(\"-\", 0, undefined, undefined, Style.SnakeCase);\nconsole.log(username); // blossom_logistical\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, Style } 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: 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.<br>The provided dictionaries can be imported from the library as a separate modules and provided in the desired order.                              | n/a           | <br>```import { uniqueUsernameGenerator, adjectives, nouns } from 'unique-username-generator';```<br>```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        | `Style` enum                        | Controls the formatting of the generated username. Available options are:<br>- `Style.LowerCase`: all lowercase (default)<br>- `Style.UpperCase`: ALL UPPERCASE<br>- `Style.Capital`: First Letter Capitalized<br>- `Style.CamelCase`: camelCaseFormatting<br>- `Style.SnakeCase`: snake_case_formatting<br>- `Style.KebabCase`: kebab-case-formatting<br>- `Style.PascalCase`: PascalCaseFormatting | Style.LowerCase | `Style.CamelCase`                                                                                                                                                                                                         |\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<a href=\"https://www.buymeacoffee.com/subhamg\" target=\"_blank\"><img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 50px !important;width: 200px !important;\" ></a>\n","readmeFilename":"README.md"}