lodash.multicombinations
_.multicombinations(collection, n)
Calculates all possible multicombinations of a certain size.
argument | description |
---|---|
collection |
A collection of distinct values to calculate the multicombinations from. |
n |
The number of values to combine. |
Returns a new array.
setup
npm
npm i lodash.multicombinations
ES module
;;
Node
;let _ = ;
browser
usage
let multicombinations = _;// => [[0, 0, 0], [0, 0, 1], [0, 1, 1], [1, 1, 1]]
Also accepts array-like values.
let multicombinations = value;// => ['aa', 'ab', 'ac', 'ad', 'ae', 'bb', 'bc', 'bd', 'be', 'cc', 'cd', 'ce', 'dd', 'de', 'ee']