Function forEach

  • produces a function that can be applied to an iterator and that will execute the handler on each value.

    The handler can be asynchronous! By default the next will only be handled when the current handler has finished. If you set options.concurrency to a higher value, you are allowing multiple handlers to run in parallel. But the next() will already be called while the (async) handler is still handling the current result, which optimizes things by not waiting for the processing to finish, before asking for the next one. Instead we'll first be asking for the next one, and then start processing of the current one. This will waste less time than using 'for await (... of ...)' while still processing things in the expected order!

    Returns

    Type Parameters

    • T = any

    Parameters

    • handler: ((T: any) => void | Promise<void>)
        • (T: any): void | Promise<void>
        • Parameters

          • T: any

          Returns void | Promise<void>

    • Optional options: {
          concurrency?: number;
      }
      • Optional concurrency?: number

    Returns ((it: Iterator<T, any, undefined> | AsyncIterator<T, any, undefined>) => void | Promise<void>)

      • (it: Iterator<T, any, undefined> | AsyncIterator<T, any, undefined>): void | Promise<void>
      • Parameters

        • it: Iterator<T, any, undefined> | AsyncIterator<T, any, undefined>

        Returns void | Promise<void>

Generated using TypeDoc