Map
Map:
object
Defined in: src/immutable/ImmutableCollections.ts:786
Unmodifiable maps: null keys/values and null queries rejected, duplicate keys rejected; iteration order is unspecified.
Type Declaration
Section titled “Type Declaration”Entry:
object
Map.Entry statics: comparingByKey, comparingByValue, copyOf.
Entry.comparingByKey()
Section titled “Entry.comparingByKey()”comparingByKey<
K,V>(cmp?): (a,b) =>number
Orders entries by key in natural order (null keys throw NullPointerException).
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”(a, b) => number
Returns
Section titled “Returns”(a, b) => number
Entry.comparingByValue()
Section titled “Entry.comparingByValue()”comparingByValue<
K,V>(cmp?): (a,b) =>number
Orders entries by value in natural order (null values throw NullPointerException).
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”(a, b) => number
Returns
Section titled “Returns”(a, b) => number
Entry.copyOf()
Section titled “Entry.copyOf()”copyOf<
K,V>(e):MapEntry<K,V>
Unmodifiable, null-free copy of e (like Map.entry); returns e itself when it already is one.
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”MapEntry<K, V>
Returns
Section titled “Returns”MapEntry<K, V>
Throws
Section titled “Throws”NullPointerException if e, its key or its value is null
of: {<
K,V>():Map<K,V>; <K,V>(k1,v1):Map<K,V>; <K,V>(k1,v1,k2,v2):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9):Map<K,V>; <K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9,k10,v10):Map<K,V>; <K,V>(…keysAndValues):Map<K,V>; } =mapOf
Map.of(k1, v1, k2, v2, ...): returns an unmodifiable map of the key/value pairs. Iteration order is unspecified.
Typed overloads cover up to 10 pairs; for more, prefer ofEntries.
Call Signature
Section titled “Call Signature”<
K,V>():Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
K
V
K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9,k10,v10):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
K
V
K
V
K
V
K
V
K
V
K
V
K
V
K
V
K
V
Returns
Section titled “Returns”Map<K, V>
Call Signature
Section titled “Call Signature”<
K,V>(…keysAndValues):Map<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”keysAndValues
Section titled “keysAndValues”…[K, V, K, V, K, V, K, V, K, V, K, V, K, V, K, V, K, V, K, V, K, V, …(K | V)[]]
Returns
Section titled “Returns”Map<K, V>
Throws
Section titled “Throws”IllegalArgumentException on an odd argument count or a duplicate key
Throws
Section titled “Throws”NullPointerException if a key or value is null or undefined
copyOf()
Section titled “copyOf()”copyOf<
K,V>(m):Map<K,V>
Returns an unmodifiable copy of m; iteration order is unspecified. Returns m itself when it already is a
map made by Map.of, Map.ofEntries or Map.copyOf.
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”Map<K, V>
Returns
Section titled “Returns”Map<K, V>
Throws
Section titled “Throws”NullPointerException if m is null or holds a null or undefined key or value
entry()
Section titled “entry()”entry<
K,V>(k,v):MapEntry<K,V>
Returns an immutable entry, for use with ofEntries; setValue throws UnsupportedOperationException.
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”MapEntry<K, V>
Throws
Section titled “Throws”NullPointerException if k or v is null or undefined
ofEntries()
Section titled “ofEntries()”ofEntries<
K,V>(…entries):Map<K,V>
Returns an unmodifiable map of the given entries (only their keys and values are copied). Iteration order is unspecified.
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”entries
Section titled “entries”…MapEntry<K, V>[]
Returns
Section titled “Returns”Map<K, V>
Throws
Section titled “Throws”IllegalArgumentException on a duplicate key
Throws
Section titled “Throws”NullPointerException if an entry, key or value is null or undefined
ofLazy()
Section titled “ofLazy()”ofLazy<
K,V>(keys,computingFunction):Map<K,V>
preview. Unmodifiable map with the given keys whose values are computed by computingFunction(key) on first access (get, getOrDefault, values/entrySet iteration, equals, hashCode, toString) and at most once per key. Failures behave as in List.ofLazy. Later changes to keys are not seen. get of a non-key is null; null queries throw NullPointerException.
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”Set<K>
computingFunction
Section titled “computingFunction”(key) => V
Returns
Section titled “Returns”Map<K, V>
Throws
Section titled “Throws”NullPointerException if keys, one of them, or computingFunction is null