UNPKG

numeric-uuid

Version:

A simple library to generate unique numeric UUIDs

86 lines (56 loc) β€’ 2.56 kB
Here’s your complete **README.md** for your `numeric-uuid` package: ````md # 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: ```sh npm install numeric-uuid ``` ```` ## πŸ”§ Usage ### Import and Generate 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 ``` ### Error Handling 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." } ``` ## πŸ“œ 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 - **GitHub:** [Jeeva0604](https://github.com/Jeeva0604/numeric-uuid) - **LinkedIn:** [Jeeva G R](https://www.linkedin.com/in/jeeva-g-r0628/) ## πŸ“„ 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! πŸš€ ```