generator-utility
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.1 • Public • Published

    build_status statements functions

    This repo contains functions that makes it easy to program with AsyncGenerators in a functional programming friendly way.

    API

    • flatten <T>(array: AsyncGenerator<T, any, unknown>[]) => AsyncGenerator<T, void, unknown>

    • generate <T, R>(fn: (el: T, index?: number, arr?: T[]) => Promise<R>) => (arr: T[]) => AsyncGenerator<R, void, unknown>

    • iterate

        interface IterateFn<T> {
            each?: EachFn<T>
            done?: DoneFn<T>
        }
        type EachFn<T> = (yielded?: T, index?: number) => Promise<any>
        type DoneFn<T> = (yieldedArray?: T[]) => Promise<any>

      <T>(generator: AsyncGenerator<T, any, unknown>) => (fn: IterateFn<T>) => Promise<void>

    • iterateSync eachFn and doneFn are synchronous function rather than returning a promise.

    Install

    npm i generator-utility

    DownloadsWeekly Downloads

    1

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    15.6 kB

    Total Files

    26

    Last publish

    Collaborators

    • nanomalloc