Simple iterator and async iterator operators.
import iterop from 'iterop';
iterop([1, 2, 3, 4, 5])
.map(x => 2 ** x)
.filter(x => x > 10)
.forEach(console.log); // 16, 32
npm install iterop
Creates an iterop
wrapper around an iterable or async iterable.
let iter = iterop([1, 2, 3]);
Creates an async iterop
wrapper around an iterable or async iterable.
let iter = await iterop.async([1, 2, 3]).forEach(x => console.log(x));
Returns a new iterable which contains the results of calling the mapping function on each input value.
iterop([1, 2, 3]).map(x => x ** 2);
Returns a new iterable which contains the values for which the supplied predicate returns true.
iterop([1, 2, 3]).filter(x => x > 1);
Executes a callback function for each input value.