mokka
Version:
Mokka Consensus Algorithm implementation in Javascript
18 lines • 610 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCombinations = void 0;
const getCombinations = (elements, n, pairs = [], pair = []) => {
return elements.reduce((accumulator, val, index) => {
pair.push(val);
if (n > 1) {
(0, exports.getCombinations)(elements.slice(index + 1), n - 1, accumulator, pair);
}
else {
accumulator.push([...pair]);
}
pair.pop();
return accumulator;
}, pairs);
};
exports.getCombinations = getCombinations;
//# sourceMappingURL=utils.js.map