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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@superhero/id-name-generator

v4.7.24

Published

A simple id generator based on a randomized characteristic and anme prefix to a base 36 microseconds timestamp.

Downloads

964

Readme

ID Name Generator

IdNameGenerator is a utility class designed to generate random, unique IDs composed of characteristics, names, and timestamps. It offers flexibility through customization, allowing you to define custom characteristics, name components, and patterns. The use of the class is intended for environments where a naming convention benefits from a recognizable ID.

Example

import IdNameGenerator from '@superhero/id-name-generator'

const idNameGenerator = new IdNameGenerator()

for(let i = 0; i < 10; i++)
{
  console.log('ID: ' + idNameGenerator.generateId())
}

// ID: emerald-voraedragorn-m4ig28sa
// ID: vermilion-miruvex-m4ig29e2
// ID: stalking-aerzar-m4ig29ul
// ID: tactful-soldraden-m4ig2abe
// ID: lavender-zenemir-m4ig2ary
// ID: nocturnal-venalok-m4ig2b7r
// ID: roaring-gonuornzen-m4ig2chr
// ID: turquoise-zenrad-m4ig2dhg
// ID: profane-aermir-m4ig2lxb
// ID: psionic-soliazar-m4ig2pd5

Features

  • Generate random characteristics from a predefined list.
  • Create unique names using customizable patterns (prefixes, roots, suffixes, connectors, etc.).
  • Produce unique IDs with a characteristic, name, and timestamp.

Installation

Include the IdNameGenerator class in your project:

# Clone or copy the file into your project

Usage

Import and Initialize

import IdNameGenerator from '@superhero/id-name-generator'

// Initialize with default configuration
const generator = new IdNameGenerator()

// Or provide custom configurations
const customConfig = 
{
  CHARACTERISTICS : ['custom1', 'custom2'],
  PREFIXES        : ['alpha'],
  ROOTS           : ['beta'],
  SUFFIXES        : ['gamma'],
  CONNECTORS      : ['x'],
  MIDFIXES        : ['delta']
}

const customGenerator = new IdNameGenerator(customConfig)

Generate Outputs

Generate a Characteristic

const characteristic = generator.generateCharacteristic()
console.log(characteristic) // Example: "red"

Generate a Name

const name = generator.generateName()
console.log(name) // Example: "aervar"

Generate a Unique ID

const id = generator.generateId()
console.log(id) // Example: "red-aervar-jw9qjxp"

Configuration Options

You can customize the following properties:

| Property | Description | Default Values | |------------------|-----------------------------------------------|--------------------------------------------| | CHARACTERISTICS| List of descriptive words for characteristics | Various colors, attributes, emotions, etc. | | PREFIXES | Starting components for names | ['aer', 'hyd', 'lum', ...] | | ROOTS | Middle components for names | ['tor', 'var', 'dom', ...] | | SUFFIXES | Ending components for names | ['nix', 'dor', 'lia', ...] | | CONNECTORS | Vowel-like connections between components | ['a', 'e', 'i', ...] | | MIDFIXES | Additional middle components for names | ['dra', 'kir', 'vel', ...] |

Patterns for Name Generation

Names are created using random patterns. Examples of patterns include:

  • [prefix + root]
  • [root + suffix]
  • [prefix + connector + root]
  • [root + connector + midfix + suffix]

Example ID Structure

A generated ID is structured as:

<characteristic>-<name>-<timestamp>

Example: blue-dratin-10sjksl.

Testing

The test suite uses Node.js's built-in testing module.

Running Tests

To run the tests, execute:

npm test

Test Coverage

▶ @superhero/id-name-generator
  ✔ Produce unique IDs on consecutive calls (2.057126ms)

  ▶ Generate
    ✔ Characteristic from the default list (0.300652ms)
    ✔ Name based on defined patterns (0.117108ms)
    ✔ Unique ID with characteristic, name, and timestamp (0.240969ms)
    ✔ Name with custom prefixes, roots, and suffixes (0.248273ms)
  ✔ Generate (1.147314ms)
✔ @superhero/id-name-generator (4.377658ms)

tests 5
suites 2
pass 5

----------------------------------------------------------------
file            | line % | branch % | funcs % | uncovered lines
----------------------------------------------------------------
index.js        | 100.00 |   100.00 |  100.00 | 
index.test.js   | 100.00 |   100.00 |  100.00 | 
----------------------------------------------------------------
all files       | 100.00 |   100.00 |  100.00 | 
----------------------------------------------------------------

License

This project is licensed under the MIT License.

Contributing

Feel free to submit issues or pull requests for improvements or additional features.