mw-username-generator
Version:
A simple username generator
77 lines (54 loc) • 2.01 kB
Markdown
# Username Generator
[](https://nodei.co/npm/mw-username-generator/)
## Introduction
A project to learn how to publish a package on npm. Should be accessible on CLI, Node and on client-size via npm installation or CDN.
Username are created from a random adjective and noun
### Output examples
>DoubtfulPomegranate <br>
>ConcernedKiosk <br>
>SuccessfulShout <br>
>TastyWit <br>
## Installation
npm install mw-username-generator
## Usage - Node
```javascript
const userNameGenerator = require('mw-username-generator');
console.log(userNameGenerator()); //Display a random username
```
## Usage - Browser
You can install and use directly from your working directory or through the following CDN :
### [UNPKG](https://unpkg.com/)
```html
<script src='https://unpkg.com/mw-username-generator'></script>
```
### [](https://www.jsdelivr.com/package/npm/mw-username-generator)
```html
<script src='https://cdn.jsdelivr.net/npm/mw-username-generator/dist/namegenerator.bundle.min.js'></script>
```
Access through CDN or local link will create a `usernameGenerator` function accesible in your script.
## Usage - CLI
On your favorite CLI :
```
npx rand-username
```
or if package installed globaly
```
rand-username
```
## Build
To have a working solution on Node and in browser I've used webpack to transpile and bundle my JS files and convert my CJS module to UMD, the following webpack config was used :
```javascript
const path = require("path");
module.exports = {
entry: "./namegenerator.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "namegenerator.bundle.js",
library: {
type: "umd",
name: "usernameGenerator", // export name after bundling
},
globalObject: "this",
},
};
```