random-digits-generator
v1.1.0
Published
A simple and lightweight npm package to generate random digits of a specified length. Created by **Sujal Patel** for fun!
Downloads
7
Readme
Random Digits Generator
A simple and lightweight npm package to generate random digits of a specified length. Created by Sujal Patel for fun!
Installation
Install the package via npm:
npm install random-digits-generatorOr using yarn:
yarn add random-digits-generatorUsage
Import the package and generate random digits:
import generateRandomDigits from 'random-digits-generator';
const randomNumber = generateRandomDigits(6); // Generates a 6-digit random number
console.log(randomNumber);API
generateRandomDigits(length: number): string
Generates a random numeric string of the given length.
Parameters:
length(number): The number of digits to generate.
Returns:
- A string containing random numeric digits.
Example:
console.log(generateRandomDigits(4)); // e.g., "2741"
console.log(generateRandomDigits(8)); // e.g., "83912047"Why Use This Package?
- Simple and easy to use
- Lightweight with zero dependencies
- Useful for generating random OTPs, numeric codes, and testing data
License
This project is licensed under the MIT License.
Author
Sujal Patel
Contributions
Feel free to submit issues or pull requests on GitHub to improve this package!
GitHub Repository
Happy coding! 🚀
