0.1.2 • Published 6 years ago

iterop v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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.

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago