Skip to content

Included Type Definitions

Latest
Compare
Choose a tag to compare
@J-Cake J-Cake released this 05 Apr 14:24
edf9f89

Iter Pipe allows you to define custom iterator functions. This exists for Synchronous iterators as well.

import { Iter } from '@j-cake/jcake-utils/iter';

for await (const i of Iter([1, 2, 3, 4, 5, 6, 7, 8])
    .pipe(async function* (nums: AsyncIterable<number>, window) {
        const buf: number[] = [];

        for await (const num of nums) {
            buf.push(num);

            if (buf.length === window)
                yield buf.splice(0, buf.length);
        }
    }, 2)
    console.log(i);

// [1, 2]
// [3, 4]
// [5, 6]
// [7, 8]

What's Changed

Full Changelog: v1.1.4...v1.2.1