https://github.com/parro-it/iterable-lookahead
Iterable wrapper that add methods to read ahead or behind current item.
https://github.com/parro-it/iterable-lookahead
Last synced: 5 months ago
JSON representation
Iterable wrapper that add methods to read ahead or behind current item.
- Host: GitHub
- URL: https://github.com/parro-it/iterable-lookahead
- Owner: parro-it
- License: mit
- Created: 2016-09-13T22:18:21.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:21:09.000Z (over 5 years ago)
- Last Synced: 2025-08-18T04:42:05.857Z (5 months ago)
- Language: JavaScript
- Size: 154 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# iterable-lookahead
[](https://greenkeeper.io/)
[](http://travis-ci.org/parro-it/iterable-lookahead)
[](https://coveralls.io/github/parro-it/iterable-lookahead)
[](https://npmjs.org/package/iterable-lookahead)
[](https://npmjs.org/package/iterable-lookahead)
> Iterable wrapper that add methods to read ahead or behind current item.
# Installation
```bash
npm install --save iterable-lookahead
```
## Usage
```js
const lookahead = require('iterable-lookahead');
const iterable = lookahead([1, 2, 3, 4]);
for (const item of iterable) {
console.log({
item,
ahead: iterable.ahead(1),
behind: iterable.behind(1)
});
}
```
or otherwise, using array spread syntax:
```js
const lookahead = require('iterable-lookahead');
for (const [item, look] of lookahead.spread([1, 2, 3, 4])) {
console.log({
item,
ahead: look.ahead(1),
behind: look.behind(1)
});
}
```
# License
The MIT License (MIT)
Copyright (c) 2016 Andrea Parodi