Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "invert"

Index

Functions

Functions

Const invertMap

  • invertMap<K, V>(src: Map<K, V>, dest?: Map<V, K>): Map<V, K>
  • Returns a new map in which the original values are used as keys and original keys as values. If dest is given, writes results in that map instead. Depending on the value type of src and/or if the inverted map should use custom key equality semantics as provided by the Map types in this package, you MUST provide a dest map, since the default dest will only be a standard ES6 Map.

    invertMap(new Map(), new Map([["a", 1], ["b", 2]]));
    // Map { 1 => 'a', 2 => 'b' }

    Type parameters

    • K

    • V

    Parameters

    • src: Map<K, V>
    • Optional dest: Map<V, K>

    Returns Map<V, K>

Const invertObj

  • invertObj(src: IObjectOf<PropertyKey>, dest?: IObjectOf<PropertyKey>): IObjectOf<string | number | symbol>
  • Returns a new object in which the original values are used as keys and original keys as values. If dest is given, writes results in that object instead.

    invertObj({a: 1, b: 2})
    // { '1': 'a', '2': 'b' }

    Parameters

    • src: IObjectOf<PropertyKey>
    • Default value dest: IObjectOf<PropertyKey> = {}

    Returns IObjectOf<string | number | symbol>

Generated using TypeDoc