uniquecodegenerator
v1.0.3
Published
The unique-id-generator npm package provides a simple and versatile solution for generating unique identifiers in JavaScript projects. It offers the flexibility to generate IDs consisting of numeric digits or a combination of alphanumeric characters. With
Downloads
223
Maintainers
Readme
uniquecodegenerator
Overview
The uniquecodegenerator
npm package provides a simple and versatile solution for generating unique identifiers in JavaScript projects. It offers the flexibility to generate codes consisting of numeric digits or a combination of alphanumeric characters. With customizable options for specifying code type (numeric or alphanumeric) and length, developers can easily integrate this package to create unique codes tailored to their application's needs.
Installation
You can install the package via npm:
npm install uniquecodegenerator
const UniqueIdGenerator = require('uniquecodegenerator');
// Create an instance of the UniqueIdGenerator
const idGenerator = new UniqueIdGenerator();
// Generate a numeric ID with a specified length
const numericId1 = idGenerator.generateUniqueId('123', 6);
// Generate another numeric ID with a specified length
const numericId2 = idGenerator.generateUniqueId('num', 6);
// Generate an alphanumeric ID with a specified length
const alphanumericId = idGenerator.generateUniqueId('abc123', 8);
console.log(numericId1); // Output: "604937"
console.log(numericId2); // Output: "892346"
console.log(alphanumericId); // Output: "R7bF9tCp"