gossamer/map
Types
A JS Map holding key-value pairs. Supports any key type (unlike
plain objects) and preserves insertion order. Mutable — methods modify
the map in place and return it for chaining.
For most Gleam use cases, prefer gleam/dict.Dict. This binding
exists for JS interop where a JS Map is specifically required.
Object keys (records, lists, tuples) are matched by JS reference
identity, not value equality — two equal-by-value tuples constructed
separately are distinct keys. Primitive keys (Int, Float,
String, Bool) use value equality.
See Map on MDN.
pub type Map(key, value)
Values
pub fn delete(
from map: Map(key, value),
key key: key,
) -> Map(key, value)
Removes the entry for the given key. Mutates the map.
pub fn entries(
of map: Map(key, value),
) -> iterator.Iterator(#(key, value), Nil, Nil)
pub fn get(
from map: Map(key, value),
key key: key,
) -> Result(value, Nil)
Returns the value associated with the given key, or an error if not found.
pub fn keys(
of map: Map(key, value),
) -> iterator.Iterator(key, Nil, Nil)
pub fn set(
in map: Map(key, value),
key key: key,
value value: value,
) -> Map(key, value)
Sets the value for the given key. Mutates the map.
pub fn values(
of map: Map(key, value),
) -> iterator.Iterator(value, Nil, Nil)