gleam/javascript/map

Types

The JavaScript Map type, a mutable collection of keys and values.

Most the time you should use the Dict type from gleam/dict in the Gleam standard library. This type may still be useful for JavaScript interop.

For further information view the MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

pub type Map(key, value)

Functions

pub fn get(a: Map(a, b), b: a) -> Result(b, Nil)

Get the value for a given key in the Map.

pub fn new() -> Map(a, b)

Create a new Map with no contained values.

pub fn set(a: Map(a, b), b: a, c: b) -> Map(a, b)

Insert a new key and value into the Map.

NOTE: This function will mutate the Map rather than immutably updating it.

pub fn size(a: Map(a, b)) -> Int

Get the number of key-value pairs in the Map.

Search Document