This package has been deprecated

Author message:

This package has been renamed to @jsq/seq for versions 0.4.0 and greater

@jsq/async-seq
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

Async sequence operators

npm version Apache 2 License Build Status

This package provides a number of functions for filtering, reducing, combining, and otherwise transforming asynchronous iterators. Where possible, the functions in this library mirror those found on Array.prototype. Unlike the methods on Array.prototype, all functions are evaluated lazily and will only be applied to values as they are produced.

All functions take an iterable as their last argument, which allows you to curry and compose operators with bind:

import {filter} from '@jsq/async-seq';

const evens = filter.bind(null, x => x % 2 === 0);

This library was designed with the Pipeline Operator ECMAScript proposal (currently at stage 1) in mind:

import {filter, map, sum, takeWhile} from '@jsq/async-seq';

function *fibonacci() {
    let i = 1, j = 1;
    do {
        yield i;
        [i, j] = [j, j + i];
    } while (true);
}

const sumOfAllEvenFibonacciNumbersUnderTenMillion = fibonacci()
    |> map.bind(null, x => x * x)
    |> filter.bind(null, x => x % 2 === 0)
    |> takeWhile.bind(null, x => x < 10000000)
    |> sum
    |> await;

For documentation of the functions provided by this library, please see the API documentation.

Readme

Keywords

Package Sidebar

Install

npm i @jsq/async-seq

Weekly Downloads

8

Version

0.3.0

License

Apache-2.0

Last publish

Collaborators

  • jsq