@nem035/combs
v1.0.0
Published
Simple utility to generate all combinations for a given array.
Downloads
51
Readme
Combs
Simple utility to generate all combinations for a given array.
Note: order doesn't matter, ["a", "b"]
and ["b", "a"]
are the same combination.
Usage
const combs = require("@nem035/combs");
const res = combs(["a", "b", "c"]);
/*
[
["a"],
["b"],
["c"],
["a", "b"],
["a", "c"],
["b", "c"],
["a", "b", "c"],
]
*/
Doesn't matter what's in the array:
const combs = require("@nem035/combs");
const res = combs(["a", 2, { value: "hi" }]);
/*
[
["a'],
[2],
[{ value: "hi' }],
["a', 2],
["a', { value: "hi' }],
[2, { value: "hi' }],
["a', 2, { value: "hi' }]
]
*/
Installation
# npm
npm i @nem035/combs
# yarn
yarn add @nem035/combs
Licence
MIT