Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Function2<T1, T2, R>

Function2 encapsulates a function taking two parameters and returning a value. It adds some useful functions to combine or transform functions.

Type parameters

  • T1

    the first parameter type

  • T2

    the second parameter type

  • R

    the result type

Hierarchy

  • Function2

Callable

  • __call(x: T1, y: T2): R
  • Invoke the function

    Parameters

    • x: T1
    • y: T2

    Returns R

Index

Methods

andThen

  • andThen<V>(fn: function): Function2<T1, T2, V>
  • Returns a new composed function which first applies the current function and then the one you pass as parameter.

    Type parameters

    • V

    Parameters

    • fn: function
        • (x: R): V
        • Parameters

          • x: R

          Returns V

    Returns Function2<T1, T2, V>

apply1

  • Applies this function partially to one argument.

    const plus5 = Function2.of(
        (x:number,y:number)=>x+y)
           .apply1(5);
    assert.equal(6, plus5(1));
    

    Parameters

    • param1: T1

    Returns Function1<T2, R>

curried

  • Returns a curried version of this function, for example:

    const plus5 = Function2.of(
        (x:number,y:number)=>x+y)
           .curried()(5);
    assert.equal(6, plus5(1));
    

    Returns Function1<T1, Function1<T2, R>>

flipped

  • Returns a version of this function taking its parameters in the reverse order.

    Returns Function2<T2, T1, R>

tupled

  • Returns a version of this function which takes a tuple instead of individual parameters. Useful in combination with Vector.zip for instance.

    Returns Function1<[T1, T2], R>

Generated using TypeDoc