immutable-math

Modules

aggregations

min()

function min(): InputFunction

Finds the minimum number in an Iterable. Accepts no parameters.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

minBy()

function minBy(valueMapper: (value: *, key: *, iter: Iterable) => Number): InputFunction

Like min, but also accepts a valueMapper function which allows you to process child properties.

Params
  • valueMapper: ValueMapper

    A function that allows you to specify what value gets processed on each item in the input Iterable.

    • ValueMapper: (value: *, key: *, iter: Iterable) => Number

      A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

      • value: *

        The value of the current item in the input Iterable.

      • key: *

        The key of the current item in the input Iterable.

      • iter: Iterable

        The original input Iterable.

      • returns: Number

        The number to use in the operation.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

max()

function max(): InputFunction

Finds the maximum number in an Iterable. Accepts no parameters.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

maxBy()

function maxBy(valueMapper: (value: *, key: *, iter: Iterable) => Number): InputFunction

Like max, but also accepts a valueMapper function which allows you to process child properties.

Params
  • valueMapper: ValueMapper

    A function that allows you to specify what value gets processed on each item in the input Iterable.

    • ValueMapper: (value: *, key: *, iter: Iterable) => Number

      A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

      • value: *

        The value of the current item in the input Iterable.

      • key: *

        The key of the current item in the input Iterable.

      • iter: Iterable

        The original input Iterable.

      • returns: Number

        The number to use in the operation.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

sum()

function sum(): InputFunction

Sums the elements in an Iterable. Accepts no parameters.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

sumBy()

function sumBy(valueMapper: (value: *, key: *, iter: Iterable) => Number): InputFunction

Like sum, but also accepts a valueMapper function which allows you to process child properties.

Params
  • valueMapper: ValueMapper

    A function that allows you to specify what value gets summed on each item in the input Iterable.

    • ValueMapper: (value: *, key: *, iter: Iterable) => Number

      A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

      • value: *

        The value of the current item in the input Iterable.

      • key: *

        The key of the current item in the input Iterable.

      • iter: Iterable

        The original input Iterable.

      • returns: Number

        The number to use in the operation.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

average()

function average(): InputFunction

Averages the elements in an Iterable. Accepts no parameters.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

averageBy()

function averageBy(valueMapper: (value: *, key: *, iter: Iterable) => Number): InputFunction

Like average, but also accepts a valueMapper function which allows you to process child properties.

Params
  • valueMapper: ValueMapper

    A function that allows you to specify what value gets averaged on each item in the input Iterable.

    • ValueMapper: (value: *, key: *, iter: Iterable) => Number

      A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

      • value: *

        The value of the current item in the input Iterable.

      • key: *

        The key of the current item in the input Iterable.

      • iter: Iterable

        The original input Iterable.

      • returns: Number

        The number to use in the operation.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

mean()

function mean(): InputFunction

An alias for {@link average}.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

meanBy()

function meanBy(valueMapper: (value: *, key: *, iter: Iterable) => Number): InputFunction

An alias for {@link averageBy}.

Params
  • valueMapper: ValueMapper

    A function that allows you to specify what value gets averaged on each item in the input Iterable.

    • ValueMapper: (value: *, key: *, iter: Iterable) => Number

      A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

      • value: *

        The value of the current item in the input Iterable.

      • key: *

        The key of the current item in the input Iterable.

      • iter: Iterable

        The original input Iterable.

      • returns: Number

        The number to use in the operation.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

median()

function median(): InputFunction

Averages the elements in an Iterable. Accepts no parameters.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

medianBy()

function medianBy(valueMapper: (value: *, key: *, iter: Iterable) => Number): InputFunction

Like median, but also accepts a valueMapper function which allows you to process child properties.

Params
  • valueMapper: ValueMapper

    A function that allows you to specify what value gets read from each item in the input Iterable.

    • ValueMapper: (value: *, key: *, iter: Iterable) => Number

      A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

      • value: *

        The value of the current item in the input Iterable.

      • key: *

        The key of the current item in the input Iterable.

      • iter: Iterable

        The original input Iterable.

      • returns: Number

        The number to use in the operation.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

transformations

percent()

function percent(): InputFunction

Calculates the percentage of each number in a Iterable compared to the sum of all numbers in the Iterable.

Returns
  • InputFunction

    A partially applied function which accepts a single Iterable, and returns the result of the operation.

percentBy()

function percentBy(valueMapper: (value: *, key: *, iter: Iterable) => Number, valueSetter: (item: *, value: *, key: *, iter: Iterable)): InputFunction

Like percent, but also accepts a valueMapper function which allows you to process child properties.

Params
  • valueMapper: (value: *, key: *, iter: Iterable) => Number

    A function that allows you to specify which value gets pulled from each item in the input Iterable when performing a calculation.

    • value: *

      The value of the current item in the input Iterable.

    • key: *

      The key of the current item in the input Iterable.

    • iter: Iterable

      The original input Iterable.

    • returns: Number

      The number to use in the operation.

  • valueSetter: (item: *, value: *, key: *, iter: Iterable)

    When provided, this function works like .map() providing you with the output of a calculation for each item in the Iterable.

    • item: *

      The current item in the Iterable.

    • value: *

      The value from the calculation.

    • key: *

      The key of the current item in the input Iterable.

    • iter: Iterable

      The original input Iterable.

Returns
  • InputFunction