Hierarchy

  • Creates a new Immutable Map.

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

    Note: Map is a factory function and not a class, and does not use the new keyword during construction.

    const { Map } = require('immutable')
    Map({ key: "value" })
    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.

    let obj = { 1: "one" }
    Object.keys(obj) // [ "1" ]
    assert.equal(obj["1"], obj[1]) // "one" === "one"

    let map = Map(obj)
    assert.notEqual(map.get("1"), map.get(1)) // "one" !== 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

    Parameters

    Returns <internal>.Map<K, V>

  • Type Parameters

    • V

    Parameters

    • obj: { [key: string]: V }
      • [key: string]: V

    Returns <internal>.Map<string, V>

  • Type Parameters

    • K extends string | symbol

    • V

    Parameters

    • obj: { [ P in string | symbol]?: V }

    Returns <internal>.Map<K, V>

Generated using TypeDoc