Skip to content

Wrapper over JS iterator, which allows filter/map/etc with chaining

License

Notifications You must be signed in to change notification settings

kashesandr/async-iter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 18, 2023
79e6c70 · Oct 18, 2023

History

17 Commits
Oct 18, 2023
Oct 11, 2023
Oct 11, 2023
Oct 11, 2023
Oct 11, 2023
Oct 11, 2023
Oct 18, 2023
Oct 11, 2023
Oct 18, 2023
Oct 11, 2023

Repository files navigation

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

About

Wrapper over JS iterator, which allows filter/map/etc with chaining

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published