npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

do-usernames

v1.0.2

Published

Get a random DigitalOcean-style username

Downloads

15

Readme

DigitalOcean username generator

This package allows one to generate DigitalOcean-style usernames. The logic for the generator is taken from IPv4's generator.

JavaScript usage

Example:

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.

Generator#SEA_OBJECTS

An array of sea objects, taken from IPv4's generator

Generator#ADJECTIVE_DESCRIPTORS

An array of adjectives, taken from IPv4's generator.

Generator#SIZE_DESCRIPTORS

An array of sizes, taken from IPv4's generator.

Generator#CREATURE_DESCRIPTORS

An array of action descriptors, taken from IPv4's generator.

Generator#COLORS

An array of ocean-related colors, taken from IPv4's generator.

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:

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.