Options
All
  • Public
  • Public/Protected
  • All
Menu

Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

Map().set(List.of(1), 'listofone').get(List.of(1));
// 'listofone'

Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

Implemented by a hash-array mapped trie.

Callable

  • Map<K, V>(): Map<K, V>
  • Map<K, V>(iter: Keyed<K, V>): Map<K, V>
  • Map<K, V>(iter: Iterable<any, Array<any>>): Map<K, V>
  • Map<K, V>(array: Array<Array<any>>): Map<K, V>
  • Map<V>(obj: object): Map<string, V>
  • Map<K, V>(iterator: Iterator<Array<any>>): Map<K, V>
  • Map<K, V>(iterable: Object): Map<K, V>
  • Creates a new Immutable Map.

    Created with the same key value pairs as the provided Iterable.Keyed or JavaScript Object or expects an Iterable of [K, V] tuple entries.

    var newMap = Map({key: "value"});
    var newMap = Map([["key", "value"]]);

    Keep in mind, when using JS objects to construct Immutable Maps, that JavaScript Object properties are always strings, even if written in a quote-less shorthand, while Immutable Maps accept keys of any type.

    var obj = { 1: "one" };
    Object.keys(obj); // [ "1" ]
    obj["1"]; // "one"
    obj[1];   // "one"
    
    var map = Map(obj);
    map.get("1"); // "one"
    map.get(1);   // undefined

    Property access for JavaScript Objects first converts the key to a string, but since Immutable Map keys can be of any type the argument to get() is not altered.

    Type parameters

    • K

    • V

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

    Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

    Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

    Map().set(List.of(1), 'listofone').get(List.of(1));
    // 'listofone'

    Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

    Implemented by a hash-array mapped trie.

    Type parameters

    • K

    • V

    Parameters

    • iter: Keyed<K, V>

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

    Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

    Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

    Map().set(List.of(1), 'listofone').get(List.of(1));
    // 'listofone'

    Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

    Implemented by a hash-array mapped trie.

    Type parameters

    • K

    • V

    Parameters

    • iter: Iterable<any, Array<any>>

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

    Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

    Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

    Map().set(List.of(1), 'listofone').get(List.of(1));
    // 'listofone'

    Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

    Implemented by a hash-array mapped trie.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<Array<any>>

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

    Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

    Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

    Map().set(List.of(1), 'listofone').get(List.of(1));
    // 'listofone'

    Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

    Implemented by a hash-array mapped trie.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Map<string, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

    Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

    Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

    Map().set(List.of(1), 'listofone').get(List.of(1));
    // 'listofone'

    Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

    Implemented by a hash-array mapped trie.

    Type parameters

    • K

    • V

    Parameters

    • iterator: Iterator<Array<any>>

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

    Map's keys can be of any type, and use Immutable.is to determine key equality. This allows the use of any value (including NaN) as a key.

    Because Immutable.is returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

    Map().set(List.of(1), 'listofone').get(List.of(1));
    // 'listofone'

    Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

    Implemented by a hash-array mapped trie.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Map<K, V>

Index

Functions

Functions

isMap

  • isMap(maybeMap: any): boolean
  • True if the provided value is a Map

    Parameters

    • maybeMap: any

    Returns boolean

of

  • of(...keyValues: any[]): Map<any, any>
  • Creates a new Map from alternating keys and values

    Parameters

    • Rest ...keyValues: any[]

    Returns Map<any, any>

Generated using TypeDoc