package server-reason-react
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3972f64a3ec22b120b40137f74e7862629b2164e5bbf8b85489d4c7b8bc13288
sha512=24a52537c091c4b278ea5e468aa6786378f8b559ed2128e824b6f84f26c283856a30e7ef01aab6101087bd53b9bdc2ecd8152c00db10bccff67221b9c67318a0
doc/server-reason-react.js/Js/Set/index.html
Module Js.SetSource
Provides bindings for ES6 Set
Mutable, insertion-ordered set matching JS Set semantics: iteration order is insertion order, re-adding an existing value keeps its position, and deleting then re-adding a value moves it to the end.
Divergences from JavaScript:
- Value equality is OCaml structural equality (
=) instead of SameValueZero. Consequentlynancompares unequal to itself (has ~value:nanisfalseafteradd ~value:nan, whereas JS Sets treatNaNas a single value), and two structurally equal but physically distinct mutable values (e.g. two arrays[|1|]) are the same element here while JS would keep them separate. values/entriesreturn a snapshot iterator: mutations made after the iterator is created are not observed, whereas JS Set iterators are live.
The Set type
fromArray values creates a set from an array, deduplicating values. A duplicated value keeps the position of its first occurrence, like JS new Set(values).
toArray set returns the values in insertion order, like JS Array.from(set).
add ~value set adds value to set (mutating it) and returns set for chaining. Adding an existing value is a no-op that keeps its original position.
delete ~value set removes value from set; returns whether the value was present.
forEach ~f set calls f value for each value in insertion order.
values set returns an iterator over the values in insertion order.