ultra-unique-id
v1.0.3
Published
A lightweight and customizable unique ID generator.
Maintainers
Readme
Unique ID Generator
A lightweight and customizable unique ID generator for JavaScript and TypeScript projects.
Features
- Generates unique IDs based on timestamps and random values.
- Supports alphanumeric (default) or alphabetic-only modes.
- Allows uppercase conversion.
- Fully typed with TypeScript support.
Installation
npm install ultra-unique-idor
yarn add ultra-unique-idUsage
Basic Example
const generateUniqueId = require("ultra-unique-id");
const id = generateUniqueId();
console.log(id); // Example: "XJ9K2Z"Custom Length
const id = generateUniqueId(10);
console.log(id); // Example: "D8JL2ZKP9X"Alphabetic-Only Mode
const id = generateUniqueId(8, { alphaNumeric: false });
console.log(id); // Example: "XJLZKPQS"Lowercase Output
const id = generateUniqueId(12, { uppercase: false });
console.log(id); // Example: "xj9k2zl8pqs3"TypeScript Usage
import generateUniqueId, { UniqueIdOptions } from "ultra-unique-id";
const options: UniqueIdOptions = {
uppercase: true,
alphaNumeric: false,
};
const id: string = generateUniqueId(8, options);
console.log(id); // Example: "XJLZKPQS"API
generateUniqueId(length?: number, options?: UniqueIdOptions): string
Parameters:
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| length | number | 6 | Length of the unique ID. |
| options.uppercase | boolean | true | Converts the ID to uppercase. |
| options.alphaNumeric | boolean | true | Includes numbers if true, letters only if false. |
Returns:
A randomly generated unique string.
Author
Created by Praveen Ram.
Contributing
Pull requests and feature requests are welcome! Feel free to open an issue in the repository.
Issues & Support
If you find a bug or need help, create an issue on GitHub Issues.
📞 Contact
For queries or suggestions, feel free to reach out:
- GitHub: @praveenrampk
- Twitter/X: @praveenrampk
- Portfolio: praveenram.dev
- Email: [email protected]
