ts-iterable-functions
    Preparing search index...

    Function _average

    • Computes the arithmetic mean of a numeric iterable, throwing if the sequence is empty.

      Parameters

      • src: Iterable<number>

        Source iterable yielding numeric values to average.

      Returns number

      The arithmetic mean of the input values.

      Error when the iterable produces no elements.

      const mean = _average([2, 4, 6]);
      console.log(mean); // 4

      or using the curried version:

      const mean = pipeInto([2, 4, 6], average());
      console.log(mean); // 4