Socket
Socket
Sign inDemoInstall

random-js

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-js

A mathematically correct random number generator library for JavaScript.


Version published
Weekly downloads
195K
decreased by-30.35%
Maintainers
1
Weekly downloads
 
Created

What is random-js?

The random-js npm package is a versatile library for generating random numbers and other random values. It provides a variety of functions to generate random integers, floating-point numbers, booleans, and even random selections from arrays. It is highly configurable and can be used for a wide range of applications, from simple random number generation to more complex random data generation.

What are random-js's main functionalities?

Random Integer Generation

Generates a random integer between the specified minimum and maximum values (inclusive).

const { Random } = require('random-js');
const random = new Random();
const randomInt = random.integer(1, 100);
console.log(randomInt);

Random Floating-Point Number Generation

Generates a random floating-point number between the specified minimum and maximum values. The third parameter specifies whether the maximum value is inclusive.

const { Random } = require('random-js');
const random = new Random();
const randomFloat = random.real(0, 1, false);
console.log(randomFloat);

Random Boolean Generation

Generates a random boolean value (true or false).

const { Random } = require('random-js');
const random = new Random();
const randomBool = random.bool();
console.log(randomBool);

Random Selection from Array

Selects a random element from the given array.

const { Random } = require('random-js');
const random = new Random();
const array = ['apple', 'banana', 'cherry'];
const randomElement = random.pick(array);
console.log(randomElement);

Other packages similar to random-js

Keywords

FAQs

Package last updated on 11 Mar 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc