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

random-helpers

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-helpers

Random helper functions

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Random Helpers

Random Helpers provides random helper functions.

Installation

npm install random-helpers

Example

var randomHelpers = require("random-helpers");

console.log('Coin flip:');
if (randomHelpers.randomBoolean()) console.log('Heads');
else console.log('Tails');

Usage

randomHelpers.randomArraySubset(array)

Returns a subset of array consisting of a random combination of sub-elements.

Parameters:

ParameterTypeDescription
arrayarrayThe array to generate a subset from

randomHelpers.randomBoolean()

Generates a random boolean.

Parameters: None

randomHelpers.randomIndex(array)

Generates a random integer in the range [0, array.length).

Parameters:

ParameterTypeDescription
arrayarrayThe array to generate an index from

randomHelpers.randomIntegerInclusive(min, max)

Generates a random integer in the range [min, max].

Parameters:

ParameterTypeDescription
minintegerThe minimum integer value to generate
maxintegerThe maximum integer value to generate

randomHelpers.randomItem(array)

Returns a random item from array.

Parameters:

ParameterTypeDescription
arrayarrayThe array to return an item from

randomHelpers.randomNumber(min, max)

Returns a random number in the range [min, max).

Parameters:

ParameterTypeDescription
minnumberThe minimum number value to generate
maxnumberThe maximum number value to generate

randomHelpers.randomVariable()

Returns a random variable, of type boolean, null, undefined, number, string, function, or object. If the variable is of type object, it will either be an array, or plain object.

Parameters: None

randomHelpers.randomVariableExcluding(typesToExclude)

Returns a random variable as in randomHelpers.randomVariable, but will not return a variable with a type specified in typesToExclude.

Parameters:

ParameterTypeDescription
typesToExcludestring or array of stringsThe data types that the random variable should not be. Valid types include boolean, null, undefined, number, string, function, object, array, and plainObject. If typesToExclude includes object, then array and plainObject are both implicitly excluded. If typesToExclude is undefined, then no data types will be excluded.

FAQs

Package last updated on 29 Aug 2017

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