Options
All
  • Public
  • Public/Protected
  • All
Menu

Package math

@typed/math

Composable math operations

Index

Variables

Const add

add: { (left: number, right: number): number; (left: number): (right: number) => number } = curry((left: number, right: number): number => left + right) as {(left: number, right: number): number(left: number): (right: number) => number}

Add together two values

Type declaration

    • (left: number, right: number): number
    • (left: number): (right: number) => number
    • Parameters

      • left: number
      • right: number

      Returns number

    • Parameters

      • left: number

      Returns (right: number) => number

        • (right: number): number
        • Parameters

          • right: number

          Returns number

Const between

between: { (from: number, to: number, num: number): number; (from: number, to: number): (num: number) => number; (from: number): { (to: number, num: number): number; (to: number): (num: number) => number } } = curry((from: number, to: number, num: number): number => Math.min(to, Math.max(from, num))) as {(from: number, to: number, num: number): number(from: number, to: number): (num: number) => number(from: number): {(to: number, num: number): number(to: number): (num: number) => number}}

Ensure a number is between two others

param

:: number

param

:: number

param

:: number

returns

:: number

Type declaration

    • (from: number, to: number, num: number): number
    • (from: number, to: number): (num: number) => number
    • (from: number): { (to: number, num: number): number; (to: number): (num: number) => number }
    • Parameters

      • from: number
      • to: number
      • num: number

      Returns number

    • Parameters

      • from: number
      • to: number

      Returns (num: number) => number

        • (num: number): number
        • Parameters

          • num: number

          Returns number

    • Parameters

      • from: number

      Returns { (to: number, num: number): number; (to: number): (num: number) => number }

        • (to: number, num: number): number
        • (to: number): (num: number) => number
        • Parameters

          • to: number
          • num: number

          Returns number

        • Parameters

          • to: number

          Returns (num: number) => number

            • (num: number): number
            • Parameters

              • num: number

              Returns number

Const decrement

decrement: (right: number) => number = add(-1)

Subtract 1 from a number

Type declaration

    • (right: number): number
    • Parameters

      • right: number

      Returns number

Const divide

divide: { (left: number, right: number): number; (left: number): (right: number) => number } = curry((left: number, right: number) => left / right)

Divide a number by another

Type declaration

    • (left: number, right: number): number
    • (left: number): (right: number) => number
    • Parameters

      • left: number
      • right: number

      Returns number

    • Parameters

      • left: number

      Returns (right: number) => number

        • (right: number): number
        • Parameters

          • right: number

          Returns number

Const divideBy

divideBy: { (left: number, right: number): number; (left: number): (right: number) => number } = curry((right: number, left: number): number => left / right)

Composition-ready division

Type declaration

    • (left: number, right: number): number
    • (left: number): (right: number) => number
    • Parameters

      • left: number
      • right: number

      Returns number

    • Parameters

      • left: number

      Returns (right: number) => number

        • (right: number): number
        • Parameters

          • right: number

          Returns number

Const increment

increment: (right: number) => number = add(1)

Add 1 to a number

Type declaration

    • (right: number): number
    • Parameters

      • right: number

      Returns number

Const modulo

modulo: { (left: number, right: number): number; (left: number): (right: number) => number } = curry(__modulo)

Modulus division

Type declaration

    • (left: number, right: number): number
    • (left: number): (right: number) => number
    • Parameters

      • left: number
      • right: number

      Returns number

    • Parameters

      • left: number

      Returns (right: number) => number

        • (right: number): number
        • Parameters

          • right: number

          Returns number

Const multiply

multiply: { (left: number, right: number): number; (left: number): (right: number) => number } = curry(__multiply) as {(left: number, right: number): number(left: number): (right: number) => number}

Multiply 2 numbers

Type declaration

    • (left: number, right: number): number
    • (left: number): (right: number) => number
    • Parameters

      • left: number
      • right: number

      Returns number

    • Parameters

      • left: number

      Returns (right: number) => number

        • (right: number): number
        • Parameters

          • right: number

          Returns number

Const pow

pow: { (exponent: number, base: number): number; (exponent: number): (base: number) => number } = curry((exponent: number, base: number): number => Math.pow(base, exponent))

Raise a number to a given power

param

:: number

param

:: number

returns

:: number

Type declaration

    • (exponent: number, base: number): number
    • (exponent: number): (base: number) => number
    • Parameters

      • exponent: number
      • base: number

      Returns number

    • Parameters

      • exponent: number

      Returns (base: number) => number

        • (base: number): number
        • Parameters

          • base: number

          Returns number

Const subtract

subtract: { (left: number, right: number): number; (left: number): (right: number) => number } = curry(__subtract)

Subtract two number

Type declaration

    • (left: number, right: number): number
    • (left: number): (right: number) => number
    • Parameters

      • left: number
      • right: number

      Returns number

    • Parameters

      • left: number

      Returns (right: number) => number

        • (right: number): number
        • Parameters

          • right: number

          Returns number

Const subtractBy

subtractBy: { (right: number, left: number): number; (right: number): (left: number) => number } = curry(__subtractBy)

Composition-ready subtraction

Type declaration

    • (right: number, left: number): number
    • (right: number): (left: number) => number
    • Parameters

      • right: number
      • left: number

      Returns number

    • Parameters

      • right: number

      Returns (left: number) => number

        • (left: number): number
        • Parameters

          • left: number

          Returns number

Functions

Const mean

  • mean(numbers: ReadonlyArray<number>): number

median

  • median(numbers: ReadonlyArray<number>): Maybe<number>

Const negate

  • negate(num: number): number

numberToMaybe

  • numberToMaybe(num: number): Maybe<number>

Const product

  • product(numbers: ReadonlyArray<number>): number

Const sum

  • sum(numbers: ReadonlyArray<number>): number

Generated using TypeDoc