New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

random-digits-generator

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-digits-generator

A simple and lightweight npm package to generate random digits of a specified length. Created by **Sujal Patel** for fun!

latest
npmnpm
Version
1.1.0
Version published
Maintainers
0
Created
Source

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-generator

Or using yarn:

yarn add random-digits-generator

Usage

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

GitHub Link

Happy coding! 🚀

FAQs

Package last updated on 12 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts