Function forEachSync

  • Applies a given function to each element of the input iterable. Returns the same iterable passed as input.

    Returns

    A function that accepts an input iterable and returns a sync iterable.

    Example

    using([1, 2, 3])
    .forEach((n) => console.log(n)) // Logs 1, 2, and 3
    .consume();

    Remarks

    Available as forEach when imported from peter-piper/sync.

    Type Parameters

    • T

      The type of elements in the input iterable.

    Parameters

    • fn: ((element: T, index: number) => void)

      A function that takes an element and its index, applies side effects, and returns nothing.

        • (element: T, index: number): void
        • Parameters

          • element: T
          • index: number

          Returns void

    Returns ((input: Iterable<T>) => Iterable<T>)

      • (input: Iterable<T>): Iterable<T>
      • Parameters

        • input: Iterable<T>

        Returns Iterable<T>

Generated using TypeDoc