Skip to content

Commit f1c5fcc

Browse files
Sync docs for belt_MapString.mli
1 parent f3e9224 commit f1c5fcc

File tree

1 file changed

+54
-67
lines changed

1 file changed

+54
-67
lines changed

jscomp/others/belt_MapString.mli

Lines changed: 54 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
(** Specalized when key type is `string`, more efficient than the generic type,
2+
its compare behavior is fixed using the built-in comparison
3+
*)
4+
5+
(* ```res prelude
6+
type key = string
7+
type t<'value>
8+
```
9+
*)
10+
111
# 2 "others/map.cppo.mli"
212
type key = string
313
# 8 "others/map.cppo.mli"
@@ -15,50 +25,43 @@ val cmp: 'v t -> 'v t -> ('v -> 'v -> int) -> int
1525

1626
val eqU: 'v t -> 'v t -> ('v -> 'v -> bool [@bs]) -> bool
1727
val eq: 'v t -> 'v t -> ('v -> 'v -> bool) -> bool
18-
(**
19-
`eq m1 m2` tests whether the maps `m1` and `m2` are
20-
equal, that is, contain equal keys and associate them with
21-
equal data.
22-
*)
28+
(** `eq(m1, m2)` tests whether the maps `m1` and `m2` are equal, that is,
29+
contain equal keys and associate them with equal data. *)
2330

2431
val findFirstByU : 'v t -> (key -> 'v -> bool [@bs]) -> (key * 'v) option
2532
val findFirstBy : 'v t -> (key -> 'v -> bool) -> (key * 'v) option
26-
(**
27-
`findFirstBy m p` uses funcion `f` to find the first key value pair
28-
to match predicate `p`.
29-
30-
```
31-
let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
32-
findFirstBy s0 (fun k v -> k = 4 ) = option (4, "4");;
33-
```
33+
(** `findFirstBy(m, p)` uses function `f` to find the first key value pair to
34+
match predicate `p`.
35+
36+
```res example
37+
let s0 = Belt.Map.String.fromArray([("4", 4), ("1", 1), ("2", 2), ("3", 3)])
38+
39+
Belt.Map.String.findFirstBy(s0, (k, _) => k == "4") == Some(("4", 4))
40+
```
3441
*)
3542

3643
val forEachU: 'v t -> (key -> 'v -> unit [@bs]) -> unit
3744
val forEach: 'v t -> (key -> 'v -> unit) -> unit
38-
(**
39-
`forEach m f` applies `f` to all bindings in map `m`.
40-
`f` receives the key as first argument, and the associated value
41-
as second argument. The bindings are passed to `f` in increasing
42-
order with respect to the ordering over the type of the keys.
43-
*)
45+
(** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the
46+
key as first argument, and the associated value as second argument. The
47+
bindings are passed to `f` in increasing order with respect to the ordering
48+
over the type of the keys. *)
4449

4550
val reduceU: 'v t -> 'v2 -> ('v2 -> key -> 'v -> 'v2 [@bs]) -> 'v2
4651
val reduce: 'v t -> 'v2 -> ('v2 -> key -> 'v -> 'v2) -> 'v2
47-
(**
48-
`reduce m a f` computes `(f kN dN ... (f k1 d1 a)...)`,
49-
where `k1 ... kN` are the keys of all bindings in `m`
50-
(in increasing order), and `d1 ... dN` are the associated data.
51-
*)
52+
(** `reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...), where k1 ...
53+
kN)` are the keys of all bindings in `m` (in increasing order), and `d1 ...
54+
dN` are the associated data. *)
5255

5356
val everyU: 'v t -> (key -> 'v -> bool [@bs]) -> bool
5457
val every: 'v t -> (key -> 'v -> bool) -> bool
55-
(** `every m p` checks if all the bindings of the map
56-
satisfy the predicate `p`. Order unspecified *)
58+
(** `every(m, p)` checks if all the bindings of the map satisfy the predicate
59+
`p`. Order unspecified *)
5760

5861
val someU: 'v t -> (key -> 'v -> bool [@bs]) -> bool
5962
val some: 'v t -> (key -> 'v -> bool) -> bool
60-
(** `some m p` checks if at least one binding of the map
61-
satisfy the predicate `p`. Order unspecified *)
63+
(** `some(m, p)` checks if at least one binding of the map satisfy the
64+
predicate `p`. Order unspecified *)
6265

6366
val size: 'v t -> int
6467

@@ -99,22 +102,18 @@ val getWithDefault: 'v t -> key -> 'v -> 'v
99102
val getExn: 'v t -> key -> 'v
100103

101104
val checkInvariantInternal: _ t -> unit
102-
(**
103-
**raise** when invariant is not held
104-
*)
105+
(** **raise** when invariant is not held *)
105106

106107
val remove: 'v t -> key -> 'v t
107-
(** `remove m x` returns a map containing the same bindings as
108-
`m`, except for `x` which is unbound in the returned map. *)
108+
(** `remove(m, x)` returns a map containing the same bindings as `m`, except
109+
for `x` which is unbound in the returned map. *)
109110

110111
val removeMany: 'v t -> key array -> 'v t
111112

112113
val set: 'v t -> key -> 'v -> 'v t
113-
(**
114-
`set m x y` returns a map containing the same bindings as
115-
`m`, plus a binding of `x` to `y`. If `x` was already bound
116-
in `m`, its previous binding disappears.
117-
*)
114+
(** `set(m, x, y)` returns a map containing the same bindings as `m`, plus a
115+
binding of `x` to `y`. If `x` was already bound in `m`, its previous
116+
binding disappears. *)
118117

119118
val updateU: 'v t -> key -> ('v option -> 'v option [@bs]) -> 'v t
120119
val update: 'v t -> key -> ('v option -> 'v option) -> 'v t
@@ -127,11 +126,9 @@ val merge:
127126
'v t -> 'v2 t ->
128127
(key -> 'v option -> 'v2 option -> 'c option) ->
129128
'c t
130-
(**
131-
`merge m1 m2 f` computes a map whose keys is a subset of keys of `m1`
132-
and of `m2`. The presence of each such binding, and the corresponding
133-
value, is determined with the function `f`.
134-
*)
129+
(** `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`
130+
and of `m2`. The presence of each such binding, and the corresponding
131+
value, is determined with the function `f`. *)
135132

136133
val mergeMany: 'v t -> (key * 'v) array -> 'v t
137134

@@ -144,8 +141,8 @@ val keep:
144141
'v t ->
145142
(key -> 'v -> bool) ->
146143
'v t
147-
(** `keep m p` returns the map with all the bindings in `m`
148-
that satisfy predicate `p`. *)
144+
(** `keep(m, p)` returns the map with all the bindings in `m` that satisfy
145+
predicate `p`. *)
149146

150147
val partitionU:
151148
'v t ->
@@ -155,33 +152,23 @@ val partition:
155152
'v t ->
156153
(key -> 'v -> bool) ->
157154
'v t * 'v t
158-
(**
159-
`partition m p` returns a pair of maps `(m1, m2)`, where
160-
`m1` contains all the bindings of `s` that satisfy the
161-
predicate `p`, and `m2` is the map with all the bindings of
162-
`s` that do not satisfy `p`.
163-
*)
155+
(** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains
156+
all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map
157+
with all the bindings of s that do not satisfy `p`. *)
164158

165159
val split: key -> 'v t -> 'v t * 'v option * 'v t
166-
(**
167-
`split x m` returns a triple `(l, data, r)`, where
168-
`l` is the map with all the bindings of `m` whose key
169-
is strictly less than `x`;
170-
`r` is the map with all the bindings of `m` whose key
171-
is strictly greater than `x`;
172-
`data` is `None` if `m` contains no binding for `x`,
173-
or `Some v` if `m` binds `v` to `x`.
174-
*)
160+
(** `split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with
161+
all the bindings of `m` whose key is strictly less than `x`; `r` is the map
162+
with all the bindings of m whose key is strictly greater than `x`; `data`
163+
is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v`
164+
to `x`. *)
175165

176166
val mapU: 'v t -> ('v -> 'v2 [@bs]) -> 'v2 t
177167
val map: 'v t -> ('v -> 'v2) -> 'v2 t
178-
(**
179-
`map m f` returns a map with same domain as `m`, where the
180-
associated value `a` of all bindings of `m` has been
181-
replaced by the result of the application of `f` to `a`.
182-
The bindings are passed to `f` in increasing order
183-
with respect to the ordering over the type of the keys.
184-
*)
168+
(** `map(m, f)` returns a map with same domain as `m`, where the associated
169+
value `a` of all bindings of `m` has been replaced by the result of the
170+
application of `f` to `a`. The bindings are passed to `f` in increasing
171+
order with respect to the ordering over the type of the keys. *)
185172

186173
val mapWithKeyU: 'v t -> (key -> 'v -> 'v2 [@bs]) -> 'v2 t
187174
val mapWithKey: 'v t -> (key -> 'v -> 'v2) -> 'v2 t

0 commit comments

Comments
 (0)