iterable-lookahead

v2.0.0
Iterable wrapper that add methods to read ahead or behind current item.
iterable generator ahead behind functional look-behind look-ahead lookbehind lookahead and 1 more...

iterable-lookahead

Greenkeeper badge Travis Build Status Coveralls NPM module NPM downloads

Iterable wrapper that add methods to read ahead or behind current item.

Installation

npm install --save iterable-lookahead

Usage

    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:

    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

npm i iterable-lookahead

Metadata

  • MIT
  • >=6
  • Andrea Parodi
  • released 6/28/2017

Downloads

Maintainers