Arrays.sampleSubset()

Randomly select an unordered subset of the array

Note that even if "Subset size" is 1, an array will still be returned (as opposed to the Pick random item" machine which always returns a single value)

Usage

Hover over inputs/exits for more info.

var Arrays = require('machinepack-arrays');


// Randomly select an unordered subset of the array

Arrays.sampleSubset({

array: [ '*' ],

size: 2,

}).execSync();

Inputs

array required

The array of items to pick from.

[ '*' ]
size required

The number of items to pick out of the array

2

Exits

error

An unexpected error occurred.

emptyArray

The provided array has no items.

success

OK.

(varies based on provided inputs)