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.
- Instantiate the
RandomGeneratorclass with an optional custom string.
const RandomGenerator = require("random-id-generate");
const generator = new RandomGenerator();- Utilize the
generatemethod to generate random strings with specified characteristics.
const randomString = generator.generate(15, ["lowercase", "numeric"]);
console.log(randomString); // Output: "a1b2c3d4e5f6g7"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['all','uppercase', 'lowercase', 'numeric', 'symbols', 'specials']-
The class supports various character groups, including lowercase, uppercase, numeric, symbols, and specials.
-
Customize string generation by specifying desired character groups in the
vocabularyparameter of thegeneratemethod. -
The
generatemethod takes optional parameters:nChars(length of the generated string) andvocabulary(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.
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"This project is licensed under the MIT License - see the LICENSE file for details.
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!