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

random-id-generate

v1.1.0

Published

A versatile NPM package for generating random strings with customizable options.

Downloads

8

Readme

RandomGenerator

Overview

RandomGenerator is a JavaScript class for generating customizable random strings. It offers flexibility and customization, allowing users to create unique combinations based on predefined character sets.

Usage

  1. Instantiate the RandomGenerator class with an optional custom string.
const RandomGenerator = require("random-id-generate");

const generator = new RandomGenerator();
  1. Utilize the generate method to generate random strings with specified characteristics.

const randomString = generator.generate(15, ["lowercase", "numeric"]);

console.log(randomString);  // Output: "a1b2c3d4e5f6g7"

Instances

const RandomGenerator = require("random-id-generate");

// Creating an instance with specific parameters
const generator = new RandomGenerator();
const upperNumericRandom = generator.instance(20, ["uppercase", "numeric"]);

console.log(upperNumericRandom(), upperNumericRandom(), upperNumericRandom());
// Output: 1F8J7B86HI5G6EI4C931 3GFBAF1DI84A12759CI9 GDA7AD957E628B1991FA

Available options

['all','uppercase', 'lowercase', 'numeric', 'symbols', 'specials']

Important Considerations

  • The class supports various character groups, including lowercase, uppercase, numeric, symbols, and specials.

  • Customize string generation by specifying desired character groups in the vocabulary parameter of the generate method.

  • The generate method takes optional parameters: nChars (length of the generated string) and vocabulary (array of character groups).

  • Easily extend or modify predefined character sets to suit your requirements.

  • Unit tests are provided to ensure the reliability of the class functionality.

Example

const generator = new RandomGenerator();

const randomString = generator.generate(15, ["lowercase", "numeric"]);

console.log(randomString); // Output: "a1b2c3d4e5f6g7"
const generator = new RandomGenerator();

const randomString = generator.generate(15, ["uppercase", "numeric"]);

console.log(randomString); // Output: "BDB5E2615942D09"

License

This project is licensed under the MIT License - see the LICENSE file for details.

Note

If you find RandomGenerator helpful in your projects, please consider starring the project on GitHub. As an individual developer, I am creating useful packages for fellow developers and your support is greatly appreciated!

To star the project, visit the GitHub repository and click on the ⭐️ icon in the top right corner.

Thank you for your support!