Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Tuple2<T, U>

Contains a pair of two values, which may or may not have the same type. Compared to the builtin typescript [T,U] type, we get equality semantics and helper functions (like mapping and so on).

Type parameters

  • T

    the first item type

  • U

    the second item type

Hierarchy

  • Tuple2

Implements

Index

Methods

Static of

  • of<T, U>(fst: T, snd: U): Tuple2<T, U>
  • Build a pair of value from both values.

    Type parameters

    • T

    • U

    Parameters

    • fst: T
    • snd: U

    Returns Tuple2<T, U>

Static ofArray

  • Build a tuple2 from javascript array. Compared to Tuple2.ofPair, it checks the length of the array and will return None in case the length isn't two. However the types of the elements aren't checked.

    Type parameters

    • T

    • U

    Parameters

    • pair: Array<T | U>

    Returns Option<Tuple2<T, U>>

Static ofPair

  • ofPair<T, U>(pair: [T, U]): Tuple2<T, U>

__computed

  • __computed(): string
  • Used by the node REPL to display values. Most of the time should be the same as toString()

    Returns string

equals

  • Two objects are equal if they represent the same value, regardless of whether they are the same object physically in memory.

    Parameters

    Returns boolean

fst

  • fst(): T
  • Extract the first value from the pair

    Returns T

hashCode

  • hashCode(): number
  • Get a number for that object. Two different values may get the same number, but one value must always get the same number. The formula can impact performance.

    Returns number

map

  • map<T1, U1>(fn: function): Tuple2<T1, U1>
  • Make a new tuple by mapping both values inside this one.

    Type parameters

    • T1

    • U1

    Parameters

    • fn: function
        • (a: T, b: U): Tuple2<T1, U1>
        • Parameters

          • a: T
          • b: U

          Returns Tuple2<T1, U1>

    Returns Tuple2<T1, U1>

map1

  • map1<V>(fn: function): Tuple2<V, U>
  • Maps the first component of this tuple to a new value.

    Type parameters

    • V

    Parameters

    • fn: function
        • (v: T): V
        • Parameters

          • v: T

          Returns V

    Returns Tuple2<V, U>

map2

  • map2<V>(fn: function): Tuple2<T, V>
  • Maps the second component of this tuple to a new value.

    Type parameters

    • V

    Parameters

    • fn: function
        • (v: U): V
        • Parameters

          • v: U

          Returns V

    Returns Tuple2<T, V>

snd

  • snd(): U
  • Extract the second value from the pair

    Returns U

toArray

  • toArray(): Array<T | U>
  • Convert the tuple to a javascript array. Compared to Tuple2.toPair, it behaves the same at runtime, the only difference is the typescript type definition.

    Returns Array<T | U>

toLinkedList

toPair

  • toPair(): [T, U]
  • Convert the tuple to a javascript pair. Compared to Tuple2.toArray, it behaves the same at runtime, the only difference is the typescript type definition.

    Returns [T, U]

toString

  • toString(): string
  • Get a human-friendly string representation of that value.

    Returns string

toVector

transform

  • transform<V>(converter: function): V
  • Transform this value to another value type. Enables fluent-style programming by chaining calls.

    Type parameters

    • V

    Parameters

    • converter: function

    Returns V

Generated using TypeDoc