iterop

0.1.2 • Public • Published

iterop

Simple iterator and async iterator operators.

Example

import iterop from 'iterop';

iterop([1, 2, 3, 4, 5])
  .map(x => 2 ** x)
  .filter(x => x > 10)
  .forEach(console.log); // 16, 32

Install

npm install iterop

API

iter(iterable)

Creates an iterop wrapper around an iterable or async iterable.

let iter = iterop([1, 2, 3]);

iter.async(iterable)

Creates an async iterop wrapper around an iterable or async iterable.

let iter = await iterop.async([1, 2, 3]).forEach(x => console.log(x));

map(fn)

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);

filter(fn)

Returns a new iterable which contains the values for which the supplied predicate returns true.

iterop([1, 2, 3]).filter(x => x > 1);

forEach(fn)

Executes a callback function for each input value.

Package Sidebar

Install

npm i iterop

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

5.95 kB

Total Files

10

Last publish

Collaborators

  • zenparsing