Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/melkir/combination-iterator
Iterate by combination in a list
https://github.com/melkir/combination-iterator
Last synced: 2 days ago
JSON representation
Iterate by combination in a list
- Host: GitHub
- URL: https://github.com/melkir/combination-iterator
- Owner: melkir
- License: mit
- Created: 2018-02-23T14:13:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-20T01:53:57.000Z (about 1 month ago)
- Last Synced: 2024-12-17T09:24:17.592Z (11 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# combination-iterator [![Build Status](https://travis-ci.org/melkir/combination-iterator.svg?branch=master)](https://travis-ci.org/melkir/combination-iterator) [![codecov](https://codecov.io/gh/melkir/combination-iterator/branch/master/graph/badge.svg)](https://codecov.io/gh/melkir/combination-iterator)
> Iterate by combination values in a list
[![Combination][picture]](https://en.wikibooks.org/wiki/Probability/Combinatorics)
## Install
```
$ npm install combination-iterator
```## Usage
### Array
```js
const combinationIterator = require('combination-iterator');const it = combinationIterator(['a', 'b', 'c']);
it.next(); // => { value: [ 'a', 'b' ], done: false }
it.next(); // => { value: [ 'a', 'c' ], done: false }
it.next(); // => { value: [ 'b', 'c' ], done: false }
it.next(); // => { value: undefined, done: true }
```### Object
```js
const it = combinationIterator({
1: 'a',
2: 'b',
3: 'c'
});// Same bahavior as arrays
it.next(); // => { value: [ 'a', 'b' ], done: false }
```## License
MIT © Thibaut Vieux
[picture]: https://upload.wikimedia.org/wikipedia/commons/3/3b/Combination.png