@@ -68,6 +68,8 @@ external fromIterator: Core__Iterator.t<'a> => t<'a> = "Set"
68
68
/**
69
69
Returns the size, the number of unique values, of the set.
70
70
71
+ See [`Set.prototype.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size) on MDN.
72
+
71
73
## Examples
72
74
```rescript
73
75
let set = Set.make()
@@ -85,6 +87,8 @@ external size: t<'a> => int = "size"
85
87
/**
86
88
Clears all entries in the set.
87
89
90
+ See [`Set.clear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear) on MDN.
91
+
88
92
## Examples
89
93
```rescript
90
94
let set = Set.make()
@@ -102,6 +106,8 @@ external clear: t<'a> => unit = "clear"
102
106
/**
103
107
Adds a new value to the set.
104
108
109
+ See [`Set.add`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add) on MDN.
110
+
105
111
## Examples
106
112
```rescript
107
113
let set = Set.make()
@@ -114,6 +120,8 @@ external add: (t<'a>, 'a) => unit = "add"
114
120
/**
115
121
Deletes the provided `value` from the set. Returns a `bool` for whether the value existed, and was deleted.
116
122
123
+ See [`Set.delete`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete) on MDN.
124
+
117
125
## Examples
118
126
```rescript
119
127
let set = Set.make()
@@ -131,6 +139,8 @@ external delete: (t<'a>, 'a) => bool = "delete"
131
139
/**
132
140
Checks whether the set has a specific value.
133
141
142
+ See [`Set.has`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has) on MDN.
143
+
134
144
## Examples
135
145
```rescript
136
146
let set = Set.make()
@@ -148,6 +158,8 @@ external has: (t<'a>, 'a) => bool = "has"
148
158
/**
149
159
Iterates through all values of the set.
150
160
161
+ See [`Set.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach) on MDN.
162
+
151
163
## Examples
152
164
```rescript
153
165
let set = Set.make()
@@ -165,6 +177,8 @@ external forEach: (t<'a>, 'a => unit) => unit = "forEach"
165
177
/**
166
178
Returns an iterator that holds all values of the set.
167
179
180
+ See [`Set.values`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values) on MDN.
181
+
168
182
## Examples
169
183
```rescript
170
184
let set = Set.make()
@@ -183,3 +197,122 @@ Console.log(set->Set.values->Iterator.toArray)
183
197
*/
184
198
@send
185
199
external values: t<'a> => Core__Iterator.t<'a> = "values"
200
+
201
+ /**
202
+ Returns a new set with the values of the set that are not in the other set.
203
+
204
+ See [`Set.difference`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference) on MDN.
205
+
206
+ ## Examples
207
+ ```rescript
208
+ let set1 = Set.fromArray(["apple", "orange", "banana"])
209
+ let set2 = Set.fromArray(["apple", "banana", "pear"])
210
+ set1->Set.difference(set2) // Set.fromArray(["orange"])
211
+ ```
212
+ */
213
+ @send
214
+ external difference: (t<'a>, t<'a>) => t<'a> = "difference"
215
+
216
+ /**
217
+ Returns a new set with the values containing the values which are in either the set, but not in both.
218
+
219
+ See [`Set.symmetricDifference`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference) on MDN.
220
+
221
+ ## Examples
222
+ ```rescript
223
+ let set1 = Set.fromArray(["apple", "orange", "banana"])
224
+ let set2 = Set.fromArray(["apple", "banana", "pear"])
225
+ set1->Set.symmetricDifference(set2) // Set.fromArray(["orange", "pear"])
226
+ ```
227
+
228
+ */
229
+ @send
230
+ external symmetricDifference: (t<'a>, t<'a>) => t<'a> = "symmetricDifference"
231
+
232
+ /**
233
+ Returns a new set with the values containing the values which are in both the set and the other set.
234
+
235
+ See [`Set.intersection`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection) on MDN.
236
+
237
+ ## Examples
238
+ ```rescript
239
+ let set1 = Set.fromArray(["apple", "orange", "banana"])
240
+ let set2 = Set.fromArray(["apple", "banana", "pear"])
241
+ set1->Set.intersection(set2) // Set.fromArray(["apple", "banana"])
242
+ ```
243
+ */
244
+ @send
245
+ external intersection: (t<'a>, t<'a>) => t<'a> = "intersection"
246
+
247
+ /**
248
+ Returns a bool indicating if this set has no elements in common with the given set.
249
+
250
+ See [`Set.isDisjointFrom`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom) on MDN.
251
+
252
+ ## Examples
253
+ ```rescript
254
+ let set1 = Set.fromArray(["apple", "orange", "banana"])
255
+ let set2 = Set.fromArray(["kiwi", "melon", "pear"])
256
+ set1->Set.isDisjointFrom(set2) // true
257
+ ```
258
+ */
259
+ @send
260
+ external isDisjointFrom: (t<'a>, t<'a>) => bool = "isDisjointFrom"
261
+
262
+ /**
263
+ Returns a bool indicating if the all values in the set are in the given set.
264
+
265
+ See [`Set.isSubsetOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf) on MDN.
266
+
267
+ ## Examples
268
+ ```rescript
269
+ let set1 = Set.fromArray(["apple", "banana"])
270
+ let set2 = Set.fromArray(["apple", "banana", "pear"])
271
+ set1->Set.isSubsetOf(set2) // true
272
+ ```
273
+ */
274
+ @send
275
+ external isSubsetOf: (t<'a>, t<'a>) => bool = "isSubsetOf"
276
+
277
+ /**
278
+ Returns a bool indicating if the all values in the given set are in the set.
279
+
280
+ See [`Set.isSupersetOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf) on MDN.
281
+
282
+ ## Examples
283
+ ```rescript
284
+ let set1 = Set.fromArray(["apple", "banana", "pear"])
285
+ let set2 = Set.fromArray(["apple", "banana"])
286
+ set1->Set.isSupersetOf(set2) // true
287
+ ```
288
+ */
289
+ @send
290
+ external isSupersetOf: (t<'a>, t<'a>) => bool = "isSupersetOf"
291
+
292
+ /**
293
+ Returns a new set with the values of the set that are in both the set and the other set.
294
+
295
+ See [`Set.union`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union) on MDN.
296
+
297
+ ## Examples
298
+ ```rescript
299
+ let set1 = Set.fromArray(["apple", "orange", "banana"])
300
+ let set2 = Set.fromArray(["apple", "banana", "pear"])
301
+ set1->Set.union(set2) // Set.fromArray(["apple", "orange", "banana", "pear"])
302
+ ```
303
+ */
304
+ @send
305
+ external union: (t<'a>, t<'a>) => t<'a> = "union"
306
+
307
+ /**
308
+ `toArray(set)` returns an array of all values of the set.
309
+
310
+ See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) on MDN.
311
+
312
+ ## Examples
313
+ ```rescript
314
+ let set = Set.fromArray(["apple", "orange", "apple", "banana"])
315
+ set->Set.toArray // ["apple", "orange", "banana"]
316
+ ```
317
+ */
318
+ external toArray: t<'a> => array<'a> = "Array.from"
0 commit comments