package server-reason-react
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3972f64a3ec22b120b40137f74e7862629b2164e5bbf8b85489d4c7b8bc13288
sha512=24a52537c091c4b278ea5e468aa6786378f8b559ed2128e824b6f84f26c283856a30e7ef01aab6101087bd53b9bdc2ecd8152c00db10bccff67221b9c67318a0
doc/server-reason-react.js/Js/Map/index.html
Module Js.MapSource
Provides 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:
- Key equality is OCaml structural equality (
=) instead of SameValueZero. Consequentlynankeys compare unequal to themselves (has ~key:nanisfalseafterset ~key:nan, whereas JS Maps treatNaNas 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/entriesreturn 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.