1.0.0 β’ Published 4 months ago
numeric-uuid v1.0.0
Hereβs your complete README.md for your numeric-uuid
package:
# numeric-uuid
A simple and efficient numeric UUID generator for Node.js. This library generates unique numeric IDs based on the current timestamp and random digits, ensuring uniqueness while maintaining simplicity.
## π Features
- Generates numeric UUIDs with a customizable length.
- Ensures uniqueness using the current timestamp.
- Supports lengths between **10** and **30** digits.
- Lightweight and dependency-free.
## π¦ Installation
Install via npm:
```bash
npm install numeric-uuid
```
π§ Usage
Import and Generate Numeric UUID
const NumericUUID = require("numeric-uuid");
// Generate a numeric UUID with the default length (20 digits)
const id1 = NumericUUID.generate();
console.log(id1); // Example: 17097012345678901234
// Generate a numeric UUID with a custom length (e.g., 25 digits)
const id2 = NumericUUID.generate(25);
console.log(id2); // Example: 1709701234567890123456789
Error Handling
If the provided length is less than 10 or greater than 30, an error will be thrown:
try {
NumericUUID.generate(35); // Throws an error
} catch (error) {
console.error(error.message); // Output: "Length must be between 10 and 30 digits."
}
π API Reference
NumericUUID.generate(length)
Parameter | Type | Default | Description |
---|---|---|---|
length | number | 20 | The length of the generated numeric UUID. Must be between 10 and 30. |
Returns: A string representing a unique numeric UUID.
π Why Use numeric-uuid
?
- β Simple & Lightweight β No external dependencies.
- β Customizable Length β Choose between 10 to 30 digits.
- β Fast Performance β Uses timestamp-based uniqueness.
- β Great for Logging, Tracking, and IDs.
π€ Connect with Me
π License
This project is licensed under the MIT License.
---
This README is **well-structured**, includes **installation**, **usage examples**, **error handling**, and **API reference**, along with your **GitHub and LinkedIn links**.
Let me know if you need any modifications! π
1.0.0
4 months ago