Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/melkir/pairwise-iterator
Iterate by pairwise values in a list
https://github.com/melkir/pairwise-iterator
Last synced: 2 days ago
JSON representation
Iterate by pairwise values in a list
- Host: GitHub
- URL: https://github.com/melkir/pairwise-iterator
- Owner: melkir
- License: mit
- Created: 2018-02-22T20:42:58.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-20T01:53:53.000Z (about 1 month ago)
- Last Synced: 2024-12-15T08:54:12.652Z (13 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pairwise-iterator [![Build Status](https://travis-ci.org/melkir/pairwise-iterator.svg?branch=master)](https://travis-ci.org/melkir/pairwise-iterator) [![codecov](https://codecov.io/gh/melkir/pairwise-iterator/branch/master/graph/badge.svg)](https://codecov.io/gh/melkir/pairwise-iterator)
> Iterate by pairwise values in a list
## Install
```
$ npm install pairwise-iterator
```## Usage
### Array
```js
const pairwiseIterator = require('pairwise-iterator');const it = pairwiseIterator(['a', 'b', 'c']);
it.next(); // => { value: [ 'a', 'b' ], done: false }
it.next(); // => { value: [ 'b', 'c' ], done: false }
it.next(); // => { value: undefined, done: true }
```### Object
```js
const it = pairwiseIterator({
1: 'a',
2: 'b',
3: 'c'
});it.next(); // => { value: [ 'a', 'b' ], done: false }
it.next(); // => { value: [ 'b', 'c' ], done: false }
it.next(); // => { value: undefined, done: true }
```## License
MIT © Thibaut Vieux