itercol

2.1.0 • Public • Published

itercol

A lazy, generator-based, JS library for handling sequences in a concise, efficient way.

API

iter(iterator)

Create a new iter by passing its constructor an iterator.

const it = iter(new Set([1, 2, 3, 4]));

iter::filter(predicate)

Return a filtered iter (lazy).

iter::map(mapper)

Return a mapped iter (lazy).

iter::limit(limit)

Return a limited iter.

iter::flatten()

Flatten any inner iterable of iterables.

Usage

const it = iter([
    iter(counter()).map(x => x * 1).limit(3),
    iter(counter()).map(x => x * 2).limit(3),
    iter(counter()).map(x => x * 3).limit(3),
]).flatten();
const arr = Array.from(it);
t.deepEqual(arr, [0, 1, 2, 0, 2, 4, 0, 3, 6]);

iter::forEach(fn)

Consume the iter object in a functional manner. This function doesn't chain.

Readme

Keywords

none

Package Sidebar

Install

npm i itercol

Weekly Downloads

3

Version

2.1.0

License

MIT

Last publish

Collaborators

  • oakfang