# do-usernames

> Get a random DigitalOcean-style username

Latest version **1.0.2** (published 2020-10-25) · BSD-2-Clause-Patent license · 0 weekly downloads

## Install

```sh
npm install do-usernames
pnpm add do-usernames
yarn add do-usernames
bun add do-usernames
```

Provides the command `do-usernames`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-10-25 |
| First published | 2020-10-24 |
| Weekly downloads | 0 |
| License | BSD-2-Clause-Patent |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Stroud |
| Maintainers | dapper-npm |
| Keywords | digitalocean, username, usernames, api |

## Links

- npm: https://www.npmjs.com/package/do-usernames
- Repository: https://github.com/dapper-gh/do-usernames-node
- Homepage: https://github.com/dapper-gh/do-usernames-node#readme
- Issues: https://github.com/dapper-gh/do-usernames-node/issues
- npm.io page: https://npm.io/package/do-usernames

## Recent versions

- 1.0.2 (latest) — 2020-10-25
- 1.0.1 — 2020-10-24
- 1.0.0 — 2020-10-24

## README

## DigitalOcean username generator

This package allows one to generate DigitalOcean-style usernames. The logic for the generator is taken from [IPv4's generator](https://github.com/MattIPv4/do_username).

#### JavaScript usage
Example:
```js
const Generator = require("do-usernames");
const myGenerator = new Generator({
  nouns: arr => [...arr, "Crustacean"],
  size: 32
});

console.log(myGenerator.getNames(5));
```

---

#### Documentation
A class, `Generator`, is exported.

`#` means static.

`.` means an instance property.

###### `Generator#SEA_CREATURES`
A list of sea creatures, taken from [IPv4's generator](https://github.com/MattIPv4/do_username).

##### `Generator#SEA_OBJECTS`
An array of sea objects, taken from [IPv4's generator](https://github.com/MattIPv4/do_username)

##### `Generator#ADJECTIVE_DESCRIPTORS`
An array of adjectives, taken from [IPv4's generator](https://github.com/MattIPv4/do_username).

##### `Generator#SIZE_DESCRIPTORS`
An array of sizes, taken from [IPv4's generator](https://github.com/MattIPv4/do_username).

##### `Generator#CREATURE_DESCRIPTORS`
An array of action descriptors, taken from [IPv4's generator](https://github.com/MattIPv4/do_username).

##### `Generator#COLORS`
An array of ocean-related colors, taken from [IPv4's generator](https://github.com/MattIPv4/do_username).

##### `Generator#SEA_LIST`
An array of sea nouns. This is created by combining `Generator#SEA_CREATURES` and `Generator#SEA_OBJECTS`.

##### `Generator#DESCRIPTORS`
An array of sea adjectives. This is created by combining `Generator#ADJECTIVE_DESCRIPTORS`, `Generator#SIZE_DESCRIPTORS`, and `Generator#CREATURE_DESCRIPTORS`.

##### `new Generator({colors?, nouns?, descriptors?, size?}?)`
Creates a `Generator`. `colors`, `nouns`, and `descriptors` can each be either a function, in which case the first argument to that function is the built-in array, and the return value is used as the word pool, or an array, in which case the array is used as the word pool. `size` must be a number (if given),

Example:
```js
new Generator({
  colors: arr => [...arr, "CoralPink"]
});
new Generator({
  colors: ["SeaGreen", "CoralPink", "Cyan"]
});
new Generator();
new Generator({
  size: 16
});
```

##### `Generator.getColors()`, `Generator.getNouns()`, `Generator.getDescriptors()`
These functions return `colors`, `nouns`, `descriptors`, and `size`, respectively. They do not clone the array, so be careful while modifying it.

##### `Generator.getSize()`
Returns the current maximum username size of the generator.

##### `Generator.setNouns(arr)`, `Generator.setColors(arr)`, `Generator.setDescriptors(arr)`
Allows for post-initalization modification of the `nouns`, `colors`, and `descriptors` array. These functions will throw if an empty array (or non-array) is given, so make sure the input is valid.

##### `Generator.setSize(num = 30)`
Sets the maximum username size of the generator.

##### `Generator.getName(amount = 1)`, `Generator.getNames(amount = 1)`
These functions are aliases for each other. They return either one value or an array of values, depending on the amount. Each value is a username generated from the word pools in the generator.

---

### CLI usage
- Run `npm i -g do-usernames`.
- Run `do-usernames [amount]`.

---

### Testing/Contributing
To contribute, clone the repository, code away, and then make a pull request when you're ready.

Once you've written code, but you want to test it, run `npm test`. This will run an automated test collection to see if your code breaks anything important. If you are adding new features, try to add tests for those features to `test/test.js`.

---
_Source: https://npm.io/package/do-usernames · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
