npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

random-helpers

v1.1.0

Published

Random helper functions

Readme

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:

|Parameter|Type|Description| |---------|----|-----------| |array|array|The 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:

|Parameter|Type|Description| |---------|----|-----------| |array|array|The array to generate an index from|

randomHelpers.randomIntegerInclusive(min, max)

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

Parameters:

|Parameter|Type|Description| |---------|----|-----------| |min|integer|The minimum integer value to generate| |max|integer|The maximum integer value to generate|

randomHelpers.randomItem(array)

Returns a random item from array.

Parameters:

|Parameter|Type|Description| |---------|----|-----------| |array|array|The array to return an item from|

randomHelpers.randomNumber(min, max)

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

Parameters:

|Parameter|Type|Description| |---------|----|-----------| |min|number|The minimum number value to generate| |max|number|The 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:

|Parameter|Type|Description| |---------|----|-----------| |typesToExclude|string or array of strings|The 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.|