1.1.0 • Published 7 months ago

ts-async-iterator v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

async-iter

A wrapper over JS iterator, which allows filter/map/etc with chaining.

Usage: Example:

    const sourceIter = (async function* () {
        for await (const item of [1, 2, 3, 4, 5]) {
            yield item;
        }
    })();

    const asyncIter = new AsyncIter(sourceIter);

    const iter =
        asyncIter
            .filter((item) => item % 2 === 0)
            .filter((item) => item > 2)
            .map((item) => item * 2)
            .map((item) => item + 1)
            .mapAsync(async (item) => item / 3)
    ;

    const result = [];
    for await (const item of iter) {
        result.push(item);
    }

    expect(result).to.deep.equal([3]);

see more details here in unit tests

1.1.0

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago