UNPKG

axax

Version:

A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).

28 lines (27 loc) 915 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const of_1 = require("../of"); const spanAll_1 = require("../spanAll"); test("spanAll", async () => { const iterables = spanAll_1.spanAll((value) => value % 2 === 0)(of_1.of(1, 2, 3, 4, 5, 6)); const result = []; for await (const iterable of iterables) { const innerResult = []; for await (const item of iterable) { innerResult.push(item); } result.push(innerResult); } expect(result).toEqual([[1], [3], [5], []]); }); test("spanAll break", async () => { const iterables = spanAll_1.spanAll((value) => value % 2 === 0)(of_1.of(1, 1, 1, 2, 3, 3, 3)); const result = []; for await (const iterable of iterables) { for await (const item of iterable) { result.push(item); break; } } expect(result).toEqual([1, 3]); });