Options
All
  • Public
  • Public/Protected
  • All
Menu

Immutable Map is an unordered Collection.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.

const { Map, List } = require('immutable');
Map().set(List([ 1 ]), 'listofone').get(List([ 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.

Index

Functions

Functions

  • isMap(maybeMap: unknown): maybeMap is <internal>.Map<unknown, unknown>
  • True if the provided value is a Map

    const { Map } = require('immutable')
    Map.isMap({}) // false
    Map.isMap(Map()) // true

    Parameters

    • maybeMap: unknown

    Returns maybeMap is <internal>.Map<unknown, unknown>

  • Creates a new Map from alternating keys and values

    const { Map } = require('immutable')
    Map.of(
    'key', 'value',
    'numerical value', 3,
    0, 'numerical key'
    )
    // Map { 0: "numerical key", "key": "value", "numerical value": 3 }
    deprecated

    Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' })

    Parameters

    • Rest ...keyValues: unknown[]

    Returns <internal>.Map<unknown, unknown>

Generated using TypeDoc