node package manager

iter

Lazily evaluated utility library

iter

Utility library for functional programming based on ES2015 generators that ensures lazy evaluation of possibly infinite ranges.

import { zipWith, tail, take, getArray } from 'iter';
 
const fibonacci = function * () {
  yield 0;
  yield 1;
  yield * zipWith((x, y) => x + y, fibonacci(), tail(fibonacci()));
};
 
getArray(take(8, fibonacci()));
  // => [0, 1, 1, 2, 3, 5, 8, 13] 
  • assertIterable(iterable)
  • compact(iterable)
  • compose(...iterables)
  • filter(filterFn, iterable)
  • getArray(iterable)
  • getIterator(iterable)
  • isIterable(iterable)
  • map(mapFn, iterable)
  • pluck(iterable)
  • slice(fromIdx, len, iterable)
  • tail(iterable)
  • take(num, iterable)
  • unqiue(iterable)
  • zipWith(zipFn, ...iterables)