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 🙏

© 2026 – Pkg Stats / Ryan Hefner

genid-pro

v1.0.15

Published

A package to generate unique Hexatridecimal IDs.

Downloads

43

Readme

genIdPro

genIdPro is a Node.js library designed for generating unique and customizable IDs with various options. It combines high entropy sources like the system's process ID and machine ID with a custom random generation mechanism to ensure uniqueness and robustness. This library provides multiple methods to generate IDs, including time-based, UUID-style, and base encoding formats. Additionally, it includes features like ID expiration, customizable separators, and dynamic prefix/suffix generation.

Features

1. Generate Unique IDs

  • The generateUnique() method ensures the uniqueness of the generated ID by checking previously generated IDs.
  • It guarantees that no two generated IDs are the same.

2. Customizable Length & Format

  • You can specify the length of the generated ID.
  • The format can be customized with prefixes, suffixes, and separators.

3. Time-Based ID Generation

  • The generateTimeBasedId() method generates IDs based on the current timestamp, ensuring a time-ordered sequence of IDs.

4. Base Encoding

  • The generateBaseEncoding() method allows you to generate IDs in different encoding formats (Base-36, Base-64, etc.).
  • You can adjust the base encoding format for the ID string generation.

5. UUID-Style IDs

  • The generateUUID() method generates IDs similar to UUID format, using the current timestamp and random entropy.

6. ID Expiration (TTL)

  • The generateWithExpiration() method generates IDs with an expiration time (Time-To-Live) defined in minutes.
  • The expiration date is embedded in the ID, allowing you to track the validity period.

7. Custom Separator

  • The generateWithCustomSeparator() method allows you to customize the separator used between different parts of the ID (e.g., timestamp, process ID, etc.).

8. Dynamic Prefix/Suffix

  • The generateWithDynamicPrefixSuffix() method adds dynamic prefixes and suffixes based on the timestamp and random part of the ID.
  • This provides an extra layer of randomness and uniqueness.

9. ID Decoding

  • The decode() method allows you to decode the generated ID into its original components (timestamp, process ID, machine ID, and random part).
  • This is useful for parsing and analyzing the ID.

10. ID Length Validation

  • The validateIdLength() method ensures the generated ID does not exceed a specified length.

11. Change ID Structure

  • The change() method allows you to modify an existing ID by changing its prefix, suffix, or length, simulating an update or restructuring of the ID.

12. Machine ID & Process ID Generation

  • The library generates unique machine and process identifiers using the system's MAC address (or hostname as fallback) and the process ID.

13. Customizable Project Name in ID Generation

  • The generateProjectId() method allows users to add a customizable project name to their IDs.
  • A maximum of 7 characters from the project name will be included to maintain length consistency.

Installation

To install genIdPro in your project, run the following command:

npm install genid-pro

Usage

  1. Import the Library

    const genIdPro = require('genid-pro');
  2. Initialize the Library Call init() to initialize the machine and process IDs:

    genIdPro.init();
  3. Generate Unique IDs Generate a unique ID with a customizable prefix, suffix, and length:

    const uniqueId = genIdPro.generateUnique('', '', 18);
    console.log(uniqueId);
  4. Generate Time-Based IDs Generate an ID based on the current timestamp:

    const timestampId = genIdPro.generateTimeBasedId('', '', 18);
    console.log(timestampId);
  5. Generate Base Encoding IDs Generate an ID in Base-36 encoding:

    const baseEncodingId = genIdPro.generateBaseEncoding('', '', 18, 36);
    console.log(baseEncodingId);
  6. Generate UUID-style IDs Generate a UUID-style ID:

    const uuidId = genIdPro.generateUUID();
    console.log(uuidId);
  7. Generate Expiration-based IDs Generate an ID with expiration (TTL):

    const ttlId = genIdPro.generateWithExpiration('', '', 60, 18);
    console.log(ttlId);
  8. Generate IDs with Custom Separator Generate an ID with a custom separator:

    const customSeparatorId = genIdPro.generateWithCustomSeparator('', '', '-', 18);
    console.log(customSeparatorId);
  9. Generate IDs with Dynamic Prefix/Suffix Generate an ID with dynamic prefix and suffix:

    const dynamicPrefixSuffixId = genIdPro.generateWithDynamicPrefixSuffix(18);
    console.log(dynamicPrefixSuffixId);
  10. Generate Project-Based IDs Generate a unique ID including a project name (max 7 characters):

    const projectId = genIdPro.generateProjectId('MyProjectName', 36);
    console.log(projectId);
  11. Decode an ID Decode a generated ID into its parts:

    const decodedId = genIdPro.decode(uniqueId);
    console.log(decodedId);
  12. Validate ID Length Validate the length of an ID:

    const isValidLength = genIdPro.validateIdLength(uniqueId, 36);
    console.log(isValidLength);
  13. Change the ID Structure Change an existing ID's structure:

    const changedId = genIdPro.change(uniqueId, 'newPrefix-', '-newSuffix', 20);
    console.log(changedId);

Methods Overview

| Method | Description | |-----------------------------------------|----------------------------------------------------------------------------------------------| | generate(prefix, suffix, length) | Generates a random ID with custom prefix, suffix, and length. | | generateUnique(prefix, suffix, length)| Generates a unique ID, ensuring no duplicates. | | generateTimeBasedId(prefix, suffix, length)| Generates a time-based ID using the current timestamp. | | generateBaseEncoding(prefix, suffix, length, base)| Generates a Base-encoded ID in the specified base (36 or 64). | | generateUUID() | Generates a UUID-style ID using timestamp and random entropy. | | generateWithExpiration(prefix, suffix, ttlMinutes, length)| Generates an ID with expiration time (TTL in minutes). | | generateWithCustomSeparator(prefix, suffix, separator, length)| Generates an ID with custom separator between parts. | | generateWithDynamicPrefixSuffix(length)| Generates an ID with dynamic prefix and suffix based on timestamp and random part. | | generateProjectId(projectName, length)| Generates a unique ID including a customizable project name (max 7 characters). | | decode(id) | Decodes a generated ID into its components. | | validateIdLength(id, maxLength) | Validates that the ID length does not exceed a specified maximum length. | | change(id, newPrefix, newSuffix, newLength)| Changes an existing ID's prefix, suffix, or length. | | checkUniqueness(id) | Checks if an ID is unique (not already generated). |

License

This package is licensed under the MIT License.