Prelude API
    Preparing search index...

    Function consume

    • Iterates through an iterable and optionally performs a side effect on each value. Unlike other generator functions, this doesn't yield values but simply consumes them.

      Type Parameters

      • T

        Type of elements in the iterable

      Parameters

      • OptionalmaybeHandle: (value: T) => unknown

        Optional function to call on each value

      Returns (values: Iterable<T>) => void

      A function that consumes an iterable and returns void

      // Log each value in an array
      consume(console.log)([1, 2, 3, 4])
      // Logs: 1, 2, 3, 4
      // Simply exhaust an iterable without doing anything with the values
      consume()([1, 2, 3, 4])