@softchef/cdk-iot-device-management
Version:
IoT device management is composed of things, thing types, thing groups, jobs, files API services. The constructs can be used independently, that are based on full-managed service to create an API Gateway & Lambda function.
29 lines (23 loc) • 614 B
JavaScript
/**
* Obliterator Power Set Function
* ===============================
*
* Iterator returning the power set of the given array.
*/
var Iterator = require('./iterator.js'),
combinations = require('./combinations.js'),
chain = require('./chain.js');
/**
* Power set.
*
* @param {array} array - Target array.
* @return {Iterator}
*/
module.exports = function powerSet(array) {
var n = array.length;
var iterators = new Array(n + 1);
iterators[0] = Iterator.of([]);
for (var i = 1; i < n + 1; i++)
iterators[i] = combinations(array, i);
return chain.apply(null, iterators);
};