Js.MapSourceProvides bindings for ES6 Map
Mutable, insertion-ordered map matching JS Map semantics: iteration order is insertion order, re-setting an existing key keeps its position, and deleting then re-adding a key moves it to the end.
Divergences from JavaScript:
=) instead of SameValueZero. Consequently nan keys compare unequal to themselves (has ~key:nan is false after set ~key:nan, whereas JS Maps treat NaN as a single key), and two structurally equal but physically distinct mutable keys (e.g. two arrays [|1|]) are the same key here while JS would keep them separate.keys/values/entries return a snapshot iterator: mutations made after the iterator is created are not observed, whereas JS Map iterators are live.The Map type
fromArray entries creates a map from an array of (key, value) pairs. Like JS new Map(entries), a duplicated key keeps the position of its first occurrence but the value of its last one.
toArray map returns the (key, value) pairs in insertion order, like JS Array.from(map).
get ~key map returns Some value if key is present, None otherwise.
set ~key ~value map sets key to value in map (mutating it) and returns map for chaining.
delete ~key map removes key from map; returns whether the key was present.
forEach ~f map calls f value key map for each entry in insertion order, like JS Map.prototype.forEach.
keys map returns an iterator over the keys in insertion order.
values map returns an iterator over the values in insertion order.