numeric-uuid
Version:
A simple library to generate unique numeric UUIDs
86 lines (56 loc) β’ 2.56 kB
Markdown
Hereβs your complete **README.md** for your `numeric-uuid` package:
````md
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.
- Generates numeric UUIDs with a customizable length.
- Ensures uniqueness using the current timestamp.
- Supports lengths between **10** and **30** digits.
- Lightweight and dependency-free.
Install via npm:
```sh
npm install numeric-uuid
```
````
```js
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
```
If the provided length is **less than 10** or **greater than 30**, an error will be thrown:
```js
try {
NumericUUID.generate(35); // Throws an error
} catch (error) {
console.error(error.message); // Output: "Length must be between 10 and 30 digits."
}
```
| 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.
- β
**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**.
- **GitHub:** [Jeeva0604](https://github.com/Jeeva0604/numeric-uuid)
- **LinkedIn:** [Jeeva G R](https://www.linkedin.com/in/jeeva-g-r0628/)
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! π
```