Package Exports
- @fczbkk/power-set-generator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@fczbkk/power-set-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Power Set Generator
Javascript utility that creates generator which yields power set of provided values, from simplest to most complex combinations, in stable order.
For example, providing this list...
['a', 'b', 'c']...will produce these combinations, in this order:
[ 'a' ]
[ 'b' ]
[ 'c' ]
[ 'a', 'b' ]
[ 'a', 'c' ]
[ 'b', 'c' ]
[ 'a', 'b', 'c' ]How to use
Install from NPM:
npm install @fczbkk/power-set-generatorThen include it in your code:
import PowerSetGenerator from '@fczbkk/power-set-generator';Then you can use it like any other generator.
In a loop:
const generator = PowerSetGenerator(['a', 'b', 'c'])
for (const result of generator) {
console.log(result)
}Via iteration protocol:
const generator = PowerSetGenerator(['a', 'b', 'c'])
let result = generator.next()
while (!result.done) {
console.log(result.value)
result = generator.next()
}Or you can generate whole set at once:
const generator = PowerSetGenerator(['a', 'b', 'c'])
const result = [...generator]