🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

random-subsets

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-subsets

Create a set of random-ordered subsets.

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

random-subsets

Create a set of random-ordered subsets.

random-subsets(array[, subsetSize])

subsetSize defaults to 2.

Returns an array of subarrays of size subsetSize. The elements of the subarrays are in random order. If array.length does not divide evenly into subsetSize the last subarray of the result will have length array.length % subsetSize.

Preserves the size and order of the input array.

Examples

Basic use

var subsets = require('random-subsets');

subsets([1, 2, 3, 4]);
//=> [[3, 4], [2, 1]]

Specify subsetSize

var subsets = require('random-subsets');

subsets([1, 2, 3, 4], 1);
//=> [[4], [2], [3], [1]]

Subset size doesn't divide evenly

var subsets = require('random-subsets');

subsets([1, 2, 3, 4], 3);
//=> [[4, 2, 3], [1]]

Keywords

random

FAQs

Package last updated on 11 Oct 2014

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