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

@reverse/random

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reverse/random

Easy random generation.

Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
10
11.11%
Maintainers
2
Weekly downloads
 
Created
Source

@reverse/random

Easy random generation.

You can install with nodejs and npm

npm i @reverse/random

Table of Contents

  • randomInt
  • chance
  • randomOf
  • randomList

Usage

randomInt(min, max)

Generates a random whole number between two values.

Parameters

  • min: Number: The minimum number to generate inclusivly.
  • max: Number: The maximum number to generate inclusivly.

Example

import { randomInt } from '@reverse/random';

randomInt(1, 5);
// Example Output: 5

chance(percent)

Returns true a percent amount of the time.

Parameters

  • percent: Number: The percent chance to return true.

Example

import { chance } from '@reverse/random';

chance(100);
// true

chance(0)
// false

chance(50)
// Example Output: true

randomOf(list)

Returns a random element from an array.

Parameters

  • list: Array: The array to pick from.

Example

import { randomOf } from '@reverse/random';

randomOf([1, 2, 3]);
// Example Output: 2

randomList(list, items, requiredValues)

Picks multiple values from an array.

Parameters

  • list: Array: The array to choose from.
  • items: Number: How many items should be returned. Default 1.
  • requiredValues: Array: The values that have to be in the returned items. Default [].

Example

import { randomList } from '@reverse/random';

randomList([1, 2, 3, 4], 1, []);
// Exanple Output: [3]

randomList([1, 2, 3, 4], 2, []);
// Exanple Output: [1, 3]

randomList([1, 2, 3, 4], 3, [3]);
// Exanple Output: [3, 3, 3]

Keywords

random

FAQs

Package last updated on 01 Aug 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