ixfx
    Preparing search index...

    Function numbersCompute

    • Returns the min, max, avg and total of the array or iterable. Any values that are invalid are silently skipped over.

      const v = [ 10, 2, 4.2, 99 ];
      const mma = numbersCompute(v);
      // Yields: { min: 2, max: 99, total: 115.2, avg: 28.8 }

      Use @ixfx/numbers.average, @ixfx/numbers.max, @ixfx/numbers.min or @ixfx/numers.total if you only need one of these.

      A start and end range can be provided if the calculation should be restricted to a part of the input array. By default the whole array is used.

      It's also possible to use an iterable as input.

      import { count } from '@ixfx/numbers';
      numbersCompute(count(5,1)); // Averages 1,2,3,4,5

      Returns NaN if the input data is empty.

      Parameters

      • data: number[] | Iterable<number, any, any> | readonly number[]
      • options: NumbersComputeOptions = {}

        Allows restriction of range that is examined

      Returns NumbersComputeResult

      {min, max, avg, total}