Options
All
  • Public
  • Public/Protected
  • All
Menu

@tsfun/function — Reference

Index

Type aliases

Curriable

Curriable<X, Xs, Y>: (x: X, ...xs: Xs) => Y

Type parameters

  • X

  • Xs: any[]

  • Y

Type declaration

    • (x: X, ...xs: Xs): Y
    • Parameters

      • x: X
      • Rest ...xs: Xs

      Returns Y

Curried

Curried<X, Xs, Y>: (...xs: Xs) => (x: X) => Y

Type parameters

  • X

  • Xs: any[]

  • Y

Type declaration

    • (...xs: Xs): (x: X) => Y
    • Parameters

      • Rest ...xs: Xs

      Returns (x: X) => Y

        • (x: X): Y
        • Parameters

          • x: X

          Returns Y

Uncurriable

Uncurriable<X, Xs, Y>: (...xs: Xs) => (x: X) => Y

Type parameters

  • X

  • Xs: any[]

  • Y

Type declaration

    • (...xs: Xs): (x: X) => Y
    • Parameters

      • Rest ...xs: Xs

      Returns (x: X) => Y

        • (x: X): Y
        • Parameters

          • x: X

          Returns Y

Uncurried

Uncurried<X, Xs, Y>: (x: X, ...xs: Xs) => Y

Type parameters

  • X

  • Xs: any[]

  • Y

Type declaration

    • (x: X, ...xs: Xs): Y
    • Parameters

      • x: X
      • Rest ...xs: Xs

      Returns Y

Variables

Const applyIter

applyIter: <X, Y>(fn: (...xs: X[]) => Y, xs: Iterable<X>) => Y = apply as any

Apply a function with an iterable of arguments

param

Function to be applied

param

Arguments to be passed to fn

returns

Result of function application

Type declaration

    • <X, Y>(fn: (...xs: X[]) => Y, xs: Iterable<X>): Y
    • Type parameters

      • X

      • Y

      Parameters

      • fn: (...xs: X[]) => Y
          • (...xs: X[]): Y
          • Parameters

            • Rest ...xs: X[]

            Returns Y

      • xs: Iterable<X>

      Returns Y

Const partialTailIter

partialTailIter: <X0, X1, Y>(fn: (x: X0, ...xs: X1[]) => Y, xs: Iterable<X1>) => (x: X0) => Y = partialTail as any

Partially apply a function

param

Function to apply

param

Iterable of all arguments except the first one

returns

Function that provides the first argument to fn

Type declaration

    • <X0, X1, Y>(fn: (x: X0, ...xs: X1[]) => Y, xs: Iterable<X1>): (x: X0) => Y
    • Type parameters

      • X0

      • X1

      • Y

      Parameters

      • fn: (x: X0, ...xs: X1[]) => Y
          • (x: X0, ...xs: X1[]): Y
          • Parameters

            • x: X0
            • Rest ...xs: X1[]

            Returns Y

      • xs: Iterable<X1>

      Returns (x: X0) => Y

        • (x: X0): Y
        • Parameters

          • x: X0

          Returns Y

Functions

Const apply

  • apply<Xs, Y>(fn: (...xs: Xs) => Y, xs: Xs): Y
  • Apply a function with an array of arguments

    Type parameters

    • Xs: readonly any[]

    • Y

    Parameters

    • fn: (...xs: Xs) => Y

      Function to be applied

        • (...xs: Xs): Y
        • Parameters

          • Rest ...xs: Xs

          Returns Y

    • xs: Xs

      Arguments to be passed to fn

    Returns Y

    Result of function application

Const call0

  • call0<Y>(fn: () => Y): Y
  • Call a nullary function

    Type parameters

    • Y

    Parameters

    • fn: () => Y

      Function to call

        • (): Y
        • Returns Y

    Returns Y

    Result of function execution

Const call1

  • call1<X, Y>(fn: (x: X) => Y, x: X): Y
  • Call a unary function

    Type parameters

    • X

    • Y

    Parameters

    • fn: (x: X) => Y

      Function to call

        • (x: X): Y
        • Parameters

          • x: X

          Returns Y

    • x: X

      Argument to pass to fn

    Returns Y

    Result of function execution

Const call2

  • call2<X0, X1, Y>(fn: (x0: X0, x1: X1) => Y, x0: X0, x1: X1): Y
  • Call a binary function

    Type parameters

    • X0

    • X1

    • Y

    Parameters

    • fn: (x0: X0, x1: X1) => Y

      Function to call

        • (x0: X0, x1: X1): Y
        • Parameters

          • x0: X0
          • x1: X1

          Returns Y

    • x0: X0

      First argument to pass to fn

    • x1: X1

      Second argument to pass to fn

    Returns Y

    Result of function execution

Const call3

  • call3<X0, X1, X2, Y>(fn: (x0: X0, x1: X1, x2: X2) => Y, x0: X0, x1: X1, x2: X2): Y
  • Call a ternary function

    Type parameters

    • X0

    • X1

    • X2

    • Y

    Parameters

    • fn: (x0: X0, x1: X1, x2: X2) => Y

      Function to call

        • (x0: X0, x1: X1, x2: X2): Y
        • Parameters

          • x0: X0
          • x1: X1
          • x2: X2

          Returns Y

    • x0: X0

      First argument to pass to fn

    • x1: X1

      Second argument to pass to fn

    • x2: X2

      Third argument to pass to fn

    Returns Y

    Result of function execution

Const callXs

  • callXs<Xs, Y>(fn: (...args: Xs) => Y, ...args: Xs): Y
  • Call a n-ary function

    Type parameters

    • Xs: any[]

    • Y

    Parameters

    • fn: (...args: Xs) => Y

      Function to call

        • (...args: Xs): Y
        • Parameters

          • Rest ...args: Xs

          Returns Y

    • Rest ...args: Xs

      Arguments to pass to fn

    Returns Y

    Result of function execution

Const compose

  • compose<X, Y, Z>(f: (y: Y) => Z, g: (x: X) => Y): (Anonymous function)
  • Compose two unary functions

    Type parameters

    • X

    • Y

    • Z

    Parameters

    • f: (y: Y) => Z

      Outer unary function

        • (y: Y): Z
        • Parameters

          • y: Y

          Returns Z

    • g: (x: X) => Y

      Inner unary function

        • (x: X): Y
        • Parameters

          • x: X

          Returns Y

    Returns (Anonymous function)

    Composite unary function

Const composeRight

  • composeRight<X, Y, Z>(f: (x: X) => Y, g: (y: Y) => Z): (Anonymous function)
  • Compose two unary functions

    Type parameters

    • X

    • Y

    • Z

    Parameters

    • f: (x: X) => Y

      Inner unary function

        • (x: X): Y
        • Parameters

          • x: X

          Returns Y

    • g: (y: Y) => Z

      Outer unary function

        • (y: Y): Z
        • Parameters

          • y: Y

          Returns Z

    Returns (Anonymous function)

    Composite n-ary function

Const composeXs

  • composeXs<Xs, Y, Z>(f: (y: Y) => Z, g: (...xs: Xs) => Y): (Anonymous function)
  • Compose an n-ary function with an unary function

    Type parameters

    • Xs: any[]

    • Y

    • Z

    Parameters

    • f: (y: Y) => Z

      Outer unary function

        • (y: Y): Z
        • Parameters

          • y: Y

          Returns Z

    • g: (...xs: Xs) => Y

      Inner n-ary function

        • (...xs: Xs): Y
        • Parameters

          • Rest ...xs: Xs

          Returns Y

    Returns (Anonymous function)

    Composite n-ary function

Const composeXsRight

  • composeXsRight<Xs, Y, Z>(f: (...xs: Xs) => Y, g: (y: Y) => Z): (Anonymous function)
  • Compose an unary function with an n-ary function

    Type parameters

    • Xs: any[]

    • Y

    • Z

    Parameters

    • f: (...xs: Xs) => Y

      Inner n-ary function

        • (...xs: Xs): Y
        • Parameters

          • Rest ...xs: Xs

          Returns Y

    • g: (y: Y) => Z

      Outer unary function

        • (y: Y): Z
        • Parameters

          • y: Y

          Returns Z

    Returns (Anonymous function)

    Composite n-ary function

Const curry

  • Postpone the first argument of a function

    Type parameters

    • X

    • Xs: any[]

    • Y

    Parameters

    Returns Curried<X, Xs, Y>

    Curried function

Const flip

  • flip<X0, X1, Y>(fn: (x0: X0, x1: X1) => Y): (Anonymous function)
  • Swap arguments of a binary function

    Type parameters

    • X0

    • X1

    • Y

    Parameters

    • fn: (x0: X0, x1: X1) => Y

      Function to swap arguments

        • (x0: X0, x1: X1): Y
        • Parameters

          • x0: X0
          • x1: X1

          Returns Y

    Returns (Anonymous function)

    Function that calls fn

Const flipXs

  • flipXs<X0, X1, Xs, Y>(fn: (x0: X0, x1: X1, ...xs: Xs) => Y): (Anonymous function)
  • Swap the first 2 arguments of an n-ary function

    Type parameters

    • X0

    • X1

    • Xs: any[]

    • Y

    Parameters

    • fn: (x0: X0, x1: X1, ...xs: Xs) => Y

      Function to swap arguments

        • (x0: X0, x1: X1, ...xs: Xs): Y
        • Parameters

          • x0: X0
          • x1: X1
          • Rest ...xs: Xs

          Returns Y

    Returns (Anonymous function)

    Function that calls fn

Const nAry

  • nAry<X>(fn: (x0: X, x1: X) => X): (Anonymous function)
  • Turn a binary function into n-ary by calling that function multiple times

    Type parameters

    • X

    Parameters

    • fn: (x0: X, x1: X) => X

      Function to apply

        • (x0: X, x1: X): X
        • Parameters

          • x0: X
          • x1: X

          Returns X

    Returns (Anonymous function)

    Function that calls fn multiple times

Const nAryRight

  • nAryRight<X>(fn: (x0: X, x1: X) => X): (Anonymous function)
  • Turn a binary function into n-ary by calling that function multiple times

    Type parameters

    • X

    Parameters

    • fn: (x0: X, x1: X) => X

      Function to apply

        • (x0: X, x1: X): X
        • Parameters

          • x0: X
          • x1: X

          Returns X

    Returns (Anonymous function)

    Function that calls fn multiple times

Const partial

  • partial<X, Xs, Y>(fn: (x: X, ...xs: Xs) => Y, x: X): (Anonymous function)
  • Partially apply a function

    Type parameters

    • X

    • Xs: any[]

    • Y

    Parameters

    • fn: (x: X, ...xs: Xs) => Y

      Function to apply

        • (x: X, ...xs: Xs): Y
        • Parameters

          • x: X
          • Rest ...xs: Xs

          Returns Y

    • x: X

      First argument of fn

    Returns (Anonymous function)

    Function that provides remaining arguments to fn

Const partialTail

  • partialTail<X, Xs, Y>(fn: (x: X, ...xs: Xs) => Y, xs: Xs): (Anonymous function)
  • Partially apply a function

    Type parameters

    • X

    • Xs: readonly any[]

    • Y

    Parameters

    • fn: (x: X, ...xs: Xs) => Y

      Function to apply

        • (x: X, ...xs: Xs): Y
        • Parameters

          • x: X
          • Rest ...xs: Xs

          Returns Y

    • xs: Xs

      Array of all arguments except the first one

    Returns (Anonymous function)

    Function that provides the first argument to fn

Const partialTailSpread

  • partialTailSpread<X, Xs, Y>(fn: (x: X, ...xs: Xs) => Y, ...xs: Xs): (Anonymous function)
  • Partially apply a function

    Type parameters

    • X

    • Xs: readonly any[]

    • Y

    Parameters

    • fn: (x: X, ...xs: Xs) => Y

      Function to apply

        • (x: X, ...xs: Xs): Y
        • Parameters

          • x: X
          • Rest ...xs: Xs

          Returns Y

    • Rest ...xs: Xs

      All arguments except the first one

    Returns (Anonymous function)

    Function that provides the first argument to fn

Const uncurry

  • Uncurry a function that is result of curry

    Type parameters

    • X

    • Xs: any[]

    • Y

    Parameters

    Returns Uncurried<X, Xs, Y>

    Uncurried function

Generated using TypeDoc