effect 3.14.2 → 3.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Effect.js +1 -1
- package/dist/cjs/Function.js +33 -12
- package/dist/cjs/Function.js.map +1 -1
- package/dist/cjs/HashSet.js +1062 -7
- package/dist/cjs/HashSet.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Data.d.ts +4 -4
- package/dist/dts/Data.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +1 -1
- package/dist/dts/Function.d.ts +99 -36
- package/dist/dts/Function.d.ts.map +1 -1
- package/dist/dts/HashSet.d.ts +1867 -155
- package/dist/dts/HashSet.d.ts.map +1 -1
- package/dist/dts/index.d.ts +250 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/esm/Effect.js +1 -1
- package/dist/esm/Function.js +33 -12
- package/dist/esm/Function.js.map +1 -1
- package/dist/esm/HashSet.js +1062 -7
- package/dist/esm/HashSet.js.map +1 -1
- package/dist/esm/index.js +250 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Data.ts +4 -4
- package/src/Effect.ts +1 -1
- package/src/Function.ts +99 -36
- package/src/HashSet.ts +1921 -163
- package/src/index.ts +250 -0
- package/src/internal/version.ts +1 -1
package/dist/cjs/HashSet.js
CHANGED
|
@@ -8,11 +8,262 @@ var HS = _interopRequireWildcard(require("./internal/hashSet.js"));
|
|
|
8
8
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
9
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
10
|
/**
|
|
11
|
+
* # HashSet
|
|
12
|
+
*
|
|
13
|
+
* An immutable `HashSet` provides a collection of unique values with efficient
|
|
14
|
+
* lookup, insertion and removal. Once created, a `HashSet` cannot be modified;
|
|
15
|
+
* any operation that would alter the set instead returns a new `HashSet` with
|
|
16
|
+
* the changes. This immutability offers benefits like predictable state
|
|
17
|
+
* management and easier reasoning about your code.
|
|
18
|
+
*
|
|
19
|
+
* ## What Problem Does It Solve?
|
|
20
|
+
*
|
|
21
|
+
* `HashSet` solves the problem of maintaining an unsorted collection where each
|
|
22
|
+
* value appears exactly once, with fast operations for checking membership and
|
|
23
|
+
* adding/removing values.
|
|
24
|
+
*
|
|
25
|
+
* ## When to Use
|
|
26
|
+
*
|
|
27
|
+
* Use `HashSet` when you need:
|
|
28
|
+
*
|
|
29
|
+
* - A collection with no duplicate values
|
|
30
|
+
* - Efficient membership testing (**`O(1)`** average complexity)
|
|
31
|
+
* - Set operations like union, intersection, and difference
|
|
32
|
+
* - An immutable data structure that preserves functional programming patterns
|
|
33
|
+
*
|
|
34
|
+
* ## Advanced Features
|
|
35
|
+
*
|
|
36
|
+
* HashSet provides operations for:
|
|
37
|
+
*
|
|
38
|
+
* - Transforming sets with map and flatMap
|
|
39
|
+
* - Filtering elements with filter
|
|
40
|
+
* - Combining sets with union, intersection and difference
|
|
41
|
+
* - Performance optimizations via mutable operations in controlled contexts
|
|
42
|
+
*
|
|
43
|
+
* ## Performance Characteristics
|
|
44
|
+
*
|
|
45
|
+
* - **Lookup** operations ({@link module:HashSet.has}): **`O(1)`** average time
|
|
46
|
+
* complexity
|
|
47
|
+
* - **Insertion** operations ({@link module:HashSet.add}): **`O(1)`** average time
|
|
48
|
+
* complexity
|
|
49
|
+
* - **Removal** operations ({@link module:HashSet.remove}): **`O(1)`** average
|
|
50
|
+
* time complexity
|
|
51
|
+
* - **Set** operations ({@link module:HashSet.union},
|
|
52
|
+
* {@link module:HashSet.intersection}): **`O(n)`** where n is the size of the
|
|
53
|
+
* smaller set
|
|
54
|
+
* - **Iteration**: **`O(n)`** where n is the size of the set
|
|
55
|
+
*
|
|
56
|
+
* The HashSet data structure implements the following traits:
|
|
57
|
+
*
|
|
58
|
+
* - {@link Iterable}: allows iterating over the values in the set
|
|
59
|
+
* - {@link Equal}: allows comparing two sets for value-based equality
|
|
60
|
+
* - {@link Pipeable}: allows chaining operations with the pipe operator
|
|
61
|
+
* - {@link Inspectable}: allows inspecting the contents of the set
|
|
62
|
+
*
|
|
63
|
+
* ## Operations Reference
|
|
64
|
+
*
|
|
65
|
+
* | Category | Operation | Description | Complexity |
|
|
66
|
+
* | ------------ | ----------------------------------- | ------------------------------------------- | ---------- |
|
|
67
|
+
* | constructors | {@link module:HashSet.empty} | Creates an empty HashSet | O(1) |
|
|
68
|
+
* | constructors | {@link module:HashSet.fromIterable} | Creates a HashSet from an iterable | O(n) |
|
|
69
|
+
* | constructors | {@link module:HashSet.make} | Creates a HashSet from multiple values | O(n) |
|
|
70
|
+
* | | | | |
|
|
71
|
+
* | elements | {@link module:HashSet.has} | Checks if a value exists in the set | O(1) avg |
|
|
72
|
+
* | elements | {@link module:HashSet.some} | Checks if any element satisfies a predicate | O(n) |
|
|
73
|
+
* | elements | {@link module:HashSet.every} | Checks if all elements satisfy a predicate | O(n) |
|
|
74
|
+
* | elements | {@link module:HashSet.isSubset} | Checks if a set is a subset of another | O(n) |
|
|
75
|
+
* | | | | |
|
|
76
|
+
* | getters | {@link module:HashSet.values} | Gets an iterator of all values | O(1) |
|
|
77
|
+
* | getters | {@link module:HashSet.toValues} | Gets an array of all values | O(n) |
|
|
78
|
+
* | getters | {@link module:HashSet.size} | Gets the number of elements | O(1) |
|
|
79
|
+
* | | | | |
|
|
80
|
+
* | mutations | {@link module:HashSet.add} | Adds a value to the set | O(1) avg |
|
|
81
|
+
* | mutations | {@link module:HashSet.remove} | Removes a value from the set | O(1) avg |
|
|
82
|
+
* | mutations | {@link module:HashSet.toggle} | Toggles a value's presence | O(1) avg |
|
|
83
|
+
* | | | | |
|
|
84
|
+
* | operations | {@link module:HashSet.difference} | Computes set difference (A - B) | O(n) |
|
|
85
|
+
* | operations | {@link module:HashSet.intersection} | Computes set intersection (A ∩ B) | O(n) |
|
|
86
|
+
* | operations | {@link module:HashSet.union} | Computes set union (A ∪ B) | O(n) |
|
|
87
|
+
* | | | | |
|
|
88
|
+
* | mapping | {@link module:HashSet.map} | Transforms each element | O(n) |
|
|
89
|
+
* | | | | |
|
|
90
|
+
* | sequencing | {@link module:HashSet.flatMap} | Transforms and flattens elements | O(n) |
|
|
91
|
+
* | | | | |
|
|
92
|
+
* | traversing | {@link module:HashSet.forEach} | Applies a function to each element | O(n) |
|
|
93
|
+
* | | | | |
|
|
94
|
+
* | folding | {@link module:HashSet.reduce} | Reduces the set to a single value | O(n) |
|
|
95
|
+
* | | | | |
|
|
96
|
+
* | filtering | {@link module:HashSet.filter} | Keeps elements that satisfy a predicate | O(n) |
|
|
97
|
+
* | | | | |
|
|
98
|
+
* | partitioning | {@link module:HashSet.partition} | Splits into two sets by a predicate | O(n) |
|
|
99
|
+
*
|
|
100
|
+
* ## Notes
|
|
101
|
+
*
|
|
102
|
+
* ### Composability with the Effect Ecosystem:
|
|
103
|
+
*
|
|
104
|
+
* This `HashSet` is designed to work seamlessly within the Effect ecosystem. It
|
|
105
|
+
* implements the {@link Iterable}, {@link Equal}, {@link Pipeable}, and
|
|
106
|
+
* {@link Inspectable} traits from Effect. This ensures compatibility with other
|
|
107
|
+
* Effect data structures and functionalities. For example, you can easily use
|
|
108
|
+
* Effect's `pipe` method to chain operations on the `HashSet`.
|
|
109
|
+
*
|
|
110
|
+
* **Equality of Elements with Effect's {@link Equal `Equal`} Trait:**
|
|
111
|
+
*
|
|
112
|
+
* This `HashSet` relies on Effect's {@link Equal} trait to determine the
|
|
113
|
+
* uniqueness of elements within the set. The way equality is checked depends on
|
|
114
|
+
* the type of the elements:
|
|
115
|
+
*
|
|
116
|
+
* - **Primitive Values:** For primitive JavaScript values like strings, numbers,
|
|
117
|
+
* booleans, `null`, and `undefined`, equality is determined by their value
|
|
118
|
+
* (similar to the `===` operator).
|
|
119
|
+
* - **Objects and Custom Types:** For objects and other custom types, equality is
|
|
120
|
+
* determined by whether those types implement the {@link Equal} interface
|
|
121
|
+
* themselves. If an element type implements `Equal`, the `HashSet` will
|
|
122
|
+
* delegate to that implementation to perform the equality check. This allows
|
|
123
|
+
* you to define custom logic for determining when two instances of your
|
|
124
|
+
* objects should be considered equal based on their properties, rather than
|
|
125
|
+
* just their object identity.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { Equal, Hash, HashSet } from "effect"
|
|
129
|
+
*
|
|
130
|
+
* class Person implements Equal.Equal {
|
|
131
|
+
* constructor(
|
|
132
|
+
* readonly id: number, // Unique identifier
|
|
133
|
+
* readonly name: string,
|
|
134
|
+
* readonly age: number
|
|
135
|
+
* ) {}
|
|
136
|
+
*
|
|
137
|
+
* // Define equality based on id, name, and age
|
|
138
|
+
* [Equal.symbol](that: Equal.Equal): boolean {
|
|
139
|
+
* if (that instanceof Person) {
|
|
140
|
+
* return (
|
|
141
|
+
* Equal.equals(this.id, that.id) &&
|
|
142
|
+
* Equal.equals(this.name, that.name) &&
|
|
143
|
+
* Equal.equals(this.age, that.age)
|
|
144
|
+
* )
|
|
145
|
+
* }
|
|
146
|
+
* return false
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* // Generate a hash code based on the unique id
|
|
150
|
+
* [Hash.symbol](): number {
|
|
151
|
+
* return Hash.hash(this.id)
|
|
152
|
+
* }
|
|
153
|
+
* }
|
|
154
|
+
*
|
|
155
|
+
* // Creating a HashSet with objects that implement the Equal interface
|
|
156
|
+
* const set = HashSet.empty().pipe(
|
|
157
|
+
* HashSet.add(new Person(1, "Alice", 30)),
|
|
158
|
+
* HashSet.add(new Person(1, "Alice", 30))
|
|
159
|
+
* )
|
|
160
|
+
*
|
|
161
|
+
* // HashSet recognizes them as equal, so only one element is stored
|
|
162
|
+
* console.log(HashSet.size(set))
|
|
163
|
+
* // Output: 1
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* **Simplifying Equality and Hashing with `Data` and `Schema`:**
|
|
167
|
+
*
|
|
168
|
+
* Effect's {@link Data} and {@link Schema `Schema.Data`} modules offer powerful
|
|
169
|
+
* ways to automatically handle the implementation of both the {@link Equal} and
|
|
170
|
+
* {@link Hash} traits for your custom data structures.
|
|
171
|
+
*
|
|
172
|
+
* - **`Data` Module:** By using constructors like `Data.struct`, `Data.tuple`,
|
|
173
|
+
* `Data.array`, or `Data.case` to define your data types, Effect
|
|
174
|
+
* automatically generates the necessary implementations for value-based
|
|
175
|
+
* equality and consistent hashing. This significantly reduces boilerplate and
|
|
176
|
+
* ensures correctness.
|
|
177
|
+
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* import { HashSet, Data, Equal } from "effect"
|
|
180
|
+
* import assert from "node:assert/strict"
|
|
181
|
+
*
|
|
182
|
+
* // Data.* implements the `Equal` traits for us
|
|
183
|
+
* const person1 = Data.struct({ id: 1, name: "Alice", age: 30 })
|
|
184
|
+
* const person2 = Data.struct({ id: 1, name: "Alice", age: 30 })
|
|
185
|
+
*
|
|
186
|
+
* assert(Equal.equals(person1, person2))
|
|
187
|
+
*
|
|
188
|
+
* const set = HashSet.empty().pipe(
|
|
189
|
+
* HashSet.add(person1),
|
|
190
|
+
* HashSet.add(person2)
|
|
191
|
+
* )
|
|
192
|
+
*
|
|
193
|
+
* // HashSet recognizes them as equal, so only one element is stored
|
|
194
|
+
* console.log(HashSet.size(set)) // Output: 1
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* - **`Schema` Module:** When defining data schemas using the {@link Schema}
|
|
198
|
+
* module, you can use `Schema.Data` to automatically include the `Equal` and
|
|
199
|
+
* `Hash` traits in the decoded objects. This is particularly important when
|
|
200
|
+
* working with `HashSet`. **For decoded objects to be correctly recognized as
|
|
201
|
+
* equal within a `HashSet`, ensure that the schema for those objects is
|
|
202
|
+
* defined using `Schema.Data`.**
|
|
203
|
+
*
|
|
204
|
+
* ```ts
|
|
205
|
+
* import { Equal, HashSet, Schema } from "effect"
|
|
206
|
+
* import assert from "node:assert/strict"
|
|
207
|
+
*
|
|
208
|
+
* // Schema.Data implements the `Equal` traits for us
|
|
209
|
+
* const PersonSchema = Schema.Data(
|
|
210
|
+
* Schema.Struct({
|
|
211
|
+
* id: Schema.Number,
|
|
212
|
+
* name: Schema.String,
|
|
213
|
+
* age: Schema.Number
|
|
214
|
+
* })
|
|
215
|
+
* )
|
|
216
|
+
*
|
|
217
|
+
* const Person = Schema.decode(PersonSchema)
|
|
218
|
+
*
|
|
219
|
+
* const person1 = Person({ id: 1, name: "Alice", age: 30 })
|
|
220
|
+
* const person2 = Person({ id: 1, name: "Alice", age: 30 })
|
|
221
|
+
*
|
|
222
|
+
* assert(Equal.equals(person1, person2)) // Output: true
|
|
223
|
+
*
|
|
224
|
+
* const set = HashSet.empty().pipe(
|
|
225
|
+
* HashSet.add(person1),
|
|
226
|
+
* HashSet.add(person2)
|
|
227
|
+
* )
|
|
228
|
+
*
|
|
229
|
+
* // HashSet thanks to Schema.Data implementation of the `Equal` trait, recognizes the two Person as equal, so only one element is stored
|
|
230
|
+
* console.log(HashSet.size(set)) // Output: 1
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* ### Interoperability with the JavaScript Runtime:
|
|
234
|
+
*
|
|
235
|
+
* To interoperate with the regular JavaScript runtime, Effect's `HashSet`
|
|
236
|
+
* provides methods to access its elements in formats readily usable by
|
|
237
|
+
* JavaScript APIs: {@link values `HashSet.values`},
|
|
238
|
+
* {@link toValues `HashSet.toValues`}
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { HashSet } from "effect"
|
|
242
|
+
*
|
|
243
|
+
* const hashSet: HashSet.HashSet<number> = HashSet.make(1, 2, 3)
|
|
244
|
+
*
|
|
245
|
+
* // Using HashSet.values to convert HashSet.HashSet<A> to IterableIterator<A>
|
|
246
|
+
* const iterable: IterableIterator<number> = HashSet.values(hashSet)
|
|
247
|
+
*
|
|
248
|
+
* console.log(...iterable) // Logs: 1 2 3
|
|
249
|
+
*
|
|
250
|
+
* // Using HashSet.toValues to convert HashSet.HashSet<A> to Array<A>
|
|
251
|
+
* const array: Array<number> = HashSet.toValues(hashSet)
|
|
252
|
+
*
|
|
253
|
+
* console.log(array) // Logs: [ 1, 2, 3 ]
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* Be mindful of performance implications (both time and space complexity) when
|
|
257
|
+
* frequently converting between Effect's immutable HashSet and mutable
|
|
258
|
+
* JavaScript data structures, especially for large collections.
|
|
259
|
+
*
|
|
260
|
+
* @module HashSet
|
|
11
261
|
* @since 2.0.0
|
|
12
262
|
*/
|
|
13
263
|
|
|
14
264
|
const TypeId = HS.HashSetTypeId;
|
|
15
265
|
/**
|
|
266
|
+
* @memberof HashSet
|
|
16
267
|
* @since 2.0.0
|
|
17
268
|
* @category refinements
|
|
18
269
|
*/
|
|
@@ -20,43 +271,331 @@ const isHashSet = exports.isHashSet = HS.isHashSet;
|
|
|
20
271
|
/**
|
|
21
272
|
* Creates an empty `HashSet`.
|
|
22
273
|
*
|
|
274
|
+
* Time complexity: **`O(1)`**
|
|
275
|
+
*
|
|
276
|
+
* @memberof HashSet
|
|
23
277
|
* @since 2.0.0
|
|
24
278
|
* @category constructors
|
|
279
|
+
* @example
|
|
280
|
+
*
|
|
281
|
+
* ```ts
|
|
282
|
+
* import { HashSet, pipe } from "effect"
|
|
283
|
+
*
|
|
284
|
+
* console.log(
|
|
285
|
+
* pipe(
|
|
286
|
+
* // Provide a type argument to create a HashSet of a specific type
|
|
287
|
+
* HashSet.empty<number>(),
|
|
288
|
+
* HashSet.add(1),
|
|
289
|
+
* HashSet.add(1), // Notice the duplicate
|
|
290
|
+
* HashSet.add(2),
|
|
291
|
+
* HashSet.toValues
|
|
292
|
+
* )
|
|
293
|
+
* ) // Output: [1, 2]
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @see Other `HashSet` constructors are {@link module:HashSet.make} {@link module:HashSet.fromIterable}
|
|
25
297
|
*/
|
|
26
298
|
const empty = exports.empty = HS.empty;
|
|
27
299
|
/**
|
|
28
300
|
* Creates a new `HashSet` from an iterable collection of values.
|
|
29
301
|
*
|
|
302
|
+
* Time complexity: **`O(n)`** where n is the number of elements in the iterable
|
|
303
|
+
*
|
|
304
|
+
* @memberof HashSet
|
|
30
305
|
* @since 2.0.0
|
|
31
306
|
* @category constructors
|
|
307
|
+
* @example
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Creating a HashSet from an Array
|
|
311
|
+
* import { HashSet, pipe } from "effect"
|
|
312
|
+
*
|
|
313
|
+
* console.log(
|
|
314
|
+
* pipe(
|
|
315
|
+
* [1, 2, 3, 4, 5, 1, 2, 3], // Array<number> is an Iterable<number>; Note the duplicates.
|
|
316
|
+
* HashSet.fromIterable,
|
|
317
|
+
* HashSet.toValues
|
|
318
|
+
* )
|
|
319
|
+
* ) // Output: [1, 2, 3, 4, 5]
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* // Creating a HashSet from a Set
|
|
326
|
+
* import { HashSet, pipe } from "effect"
|
|
327
|
+
*
|
|
328
|
+
* console.log(
|
|
329
|
+
* pipe(
|
|
330
|
+
* new Set(["apple", "banana", "orange", "apple"]), // Set<string> is an Iterable<string>
|
|
331
|
+
* HashSet.fromIterable,
|
|
332
|
+
* HashSet.toValues
|
|
333
|
+
* )
|
|
334
|
+
* ) // Output: ["apple", "banana", "orange"]
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
*
|
|
339
|
+
* ```ts
|
|
340
|
+
* // Creating a HashSet from a Generator
|
|
341
|
+
* import { HashSet } from "effect"
|
|
342
|
+
*
|
|
343
|
+
* // Generator functions return iterables
|
|
344
|
+
* function* fibonacci(n: number): Generator<number, void, unknown> {
|
|
345
|
+
* let [a, b] = [0, 1]
|
|
346
|
+
* for (let i = 0; i < n; i++) {
|
|
347
|
+
* yield a
|
|
348
|
+
* ;[a, b] = [b, a + b]
|
|
349
|
+
* }
|
|
350
|
+
* }
|
|
351
|
+
*
|
|
352
|
+
* // Create a HashSet from the first 10 Fibonacci numbers
|
|
353
|
+
* const fibonacciSet = HashSet.fromIterable(fibonacci(10))
|
|
354
|
+
*
|
|
355
|
+
* console.log(HashSet.toValues(fibonacciSet))
|
|
356
|
+
* // Outputs: [0, 1, 2, 3, 5, 8, 13, 21, 34] but in unsorted order
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
*
|
|
361
|
+
* ```ts
|
|
362
|
+
* // Creating a HashSet from another HashSet
|
|
363
|
+
* import { HashSet, pipe } from "effect"
|
|
364
|
+
*
|
|
365
|
+
* console.log(
|
|
366
|
+
* pipe(
|
|
367
|
+
* // since HashSet implements the Iterable interface, we can use it to create a new HashSet
|
|
368
|
+
* HashSet.make(1, 2, 3, 4),
|
|
369
|
+
* HashSet.fromIterable,
|
|
370
|
+
* HashSet.toValues // turns the HashSet back into an array
|
|
371
|
+
* )
|
|
372
|
+
* ) // Output: [1, 2, 3, 4]
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
*
|
|
377
|
+
* ```ts
|
|
378
|
+
* // Creating a HashSet from other Effect's data structures like Chunk
|
|
379
|
+
* import { Chunk, HashSet, pipe } from "effect"
|
|
380
|
+
*
|
|
381
|
+
* console.log(
|
|
382
|
+
* pipe(
|
|
383
|
+
* Chunk.make(1, 2, 3, 4), // Iterable<number>
|
|
384
|
+
* HashSet.fromIterable,
|
|
385
|
+
* HashSet.toValues // turns the HashSet back into an array
|
|
386
|
+
* )
|
|
387
|
+
* ) // Outputs: [1, 2, 3, 4]
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @see Other `HashSet` constructors are {@link module:HashSet.empty} {@link module:HashSet.make}
|
|
32
391
|
*/
|
|
33
392
|
const fromIterable = exports.fromIterable = HS.fromIterable;
|
|
34
393
|
/**
|
|
35
394
|
* Construct a new `HashSet` from a variable number of values.
|
|
36
395
|
*
|
|
396
|
+
* Time complexity: **`O(n)`** where n is the number of elements
|
|
397
|
+
*
|
|
398
|
+
* @memberof HashSet
|
|
37
399
|
* @since 2.0.0
|
|
38
400
|
* @category constructors
|
|
401
|
+
* @example
|
|
402
|
+
*
|
|
403
|
+
* ```ts
|
|
404
|
+
* import { Equal, Hash, HashSet, pipe } from "effect"
|
|
405
|
+
* import assert from "node:assert/strict"
|
|
406
|
+
*
|
|
407
|
+
* class Character implements Equal.Equal {
|
|
408
|
+
* readonly name: string
|
|
409
|
+
* readonly trait: string
|
|
410
|
+
*
|
|
411
|
+
* constructor(name: string, trait: string) {
|
|
412
|
+
* this.name = name
|
|
413
|
+
* this.trait = trait
|
|
414
|
+
* }
|
|
415
|
+
*
|
|
416
|
+
* // Define equality based on name, and trait
|
|
417
|
+
* [Equal.symbol](that: Equal.Equal): boolean {
|
|
418
|
+
* if (that instanceof Character) {
|
|
419
|
+
* return (
|
|
420
|
+
* Equal.equals(this.name, that.name) &&
|
|
421
|
+
* Equal.equals(this.trait, that.trait)
|
|
422
|
+
* )
|
|
423
|
+
* }
|
|
424
|
+
* return false
|
|
425
|
+
* }
|
|
426
|
+
*
|
|
427
|
+
* // Generate a hash code based on the sum of the character's name and trait
|
|
428
|
+
* [Hash.symbol](): number {
|
|
429
|
+
* return Hash.hash(this.name + this.trait)
|
|
430
|
+
* }
|
|
431
|
+
*
|
|
432
|
+
* static readonly of = (name: string, trait: string): Character => {
|
|
433
|
+
* return new Character(name, trait)
|
|
434
|
+
* }
|
|
435
|
+
* }
|
|
436
|
+
*
|
|
437
|
+
* assert.strictEqual(
|
|
438
|
+
* Equal.equals(
|
|
439
|
+
* HashSet.make(
|
|
440
|
+
* Character.of("Alice", "Curious"),
|
|
441
|
+
* Character.of("Alice", "Curious"),
|
|
442
|
+
* Character.of("White Rabbit", "Always late"),
|
|
443
|
+
* Character.of("Mad Hatter", "Tea enthusiast")
|
|
444
|
+
* ),
|
|
445
|
+
* // Is the same as adding each character to an empty set
|
|
446
|
+
* pipe(
|
|
447
|
+
* HashSet.empty(),
|
|
448
|
+
* HashSet.add(Character.of("Alice", "Curious")),
|
|
449
|
+
* HashSet.add(Character.of("Alice", "Curious")), // Alice tried to attend twice!
|
|
450
|
+
* HashSet.add(Character.of("White Rabbit", "Always late")),
|
|
451
|
+
* HashSet.add(Character.of("Mad Hatter", "Tea enthusiast"))
|
|
452
|
+
* )
|
|
453
|
+
* ),
|
|
454
|
+
* true,
|
|
455
|
+
* "`HashSet.make` and `HashSet.empty() + HashSet.add()` should be equal"
|
|
456
|
+
* )
|
|
457
|
+
*
|
|
458
|
+
* assert.strictEqual(
|
|
459
|
+
* Equal.equals(
|
|
460
|
+
* HashSet.make(
|
|
461
|
+
* Character.of("Alice", "Curious"),
|
|
462
|
+
* Character.of("Alice", "Curious"),
|
|
463
|
+
* Character.of("White Rabbit", "Always late"),
|
|
464
|
+
* Character.of("Mad Hatter", "Tea enthusiast")
|
|
465
|
+
* ),
|
|
466
|
+
* HashSet.fromIterable([
|
|
467
|
+
* Character.of("Alice", "Curious"),
|
|
468
|
+
* Character.of("Alice", "Curious"),
|
|
469
|
+
* Character.of("White Rabbit", "Always late"),
|
|
470
|
+
* Character.of("Mad Hatter", "Tea enthusiast")
|
|
471
|
+
* ])
|
|
472
|
+
* ),
|
|
473
|
+
* true,
|
|
474
|
+
* "`HashSet.make` and `HashSet.fromIterable` should be equal"
|
|
475
|
+
* )
|
|
476
|
+
* ```
|
|
477
|
+
*
|
|
478
|
+
* @see Other `HashSet` constructors are {@link module:HashSet.fromIterable} {@link module:HashSet.empty}
|
|
39
479
|
*/
|
|
40
480
|
const make = exports.make = HS.make;
|
|
41
481
|
/**
|
|
42
482
|
* Checks if the specified value exists in the `HashSet`.
|
|
43
483
|
*
|
|
484
|
+
* Time complexity: **`O(1)`** average
|
|
485
|
+
*
|
|
486
|
+
* @memberof HashSet
|
|
44
487
|
* @since 2.0.0
|
|
45
488
|
* @category elements
|
|
489
|
+
* @example
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* // Syntax
|
|
493
|
+
* import { HashSet, pipe } from "effect"
|
|
494
|
+
*
|
|
495
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
496
|
+
* pipe(HashSet.make(0, 1, 2), HashSet.has(3)) // false
|
|
497
|
+
*
|
|
498
|
+
* // or piped with the pipe function
|
|
499
|
+
* HashSet.make(0, 1, 2).pipe(HashSet.has(3)) // false
|
|
500
|
+
*
|
|
501
|
+
* // or with `data-first` API
|
|
502
|
+
* HashSet.has(HashSet.make(0, 1, 2), 3) // false
|
|
503
|
+
* ```
|
|
504
|
+
*
|
|
505
|
+
* @returns A `boolean` signaling the presence of the value in the HashSet
|
|
506
|
+
* @see Other `HashSet` elements are {@link module:HashSet.some} {@link module:HashSet.every} {@link module:HashSet.isSubset}
|
|
46
507
|
*/
|
|
47
508
|
const has = exports.has = HS.has;
|
|
48
509
|
/**
|
|
49
510
|
* Check if a predicate holds true for some `HashSet` element.
|
|
50
511
|
*
|
|
512
|
+
* Time complexity: **`O(n)`** where n is the number of elements in the set
|
|
513
|
+
*
|
|
514
|
+
* @memberof HashSet
|
|
51
515
|
* @since 2.0.0
|
|
52
516
|
* @category elements
|
|
517
|
+
* @example
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* // Syntax
|
|
521
|
+
* import { HashSet, pipe } from "effect"
|
|
522
|
+
*
|
|
523
|
+
* const set: HashSet.HashSet<number> = HashSet.make(0, 1, 2)
|
|
524
|
+
*
|
|
525
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
526
|
+
* pipe(
|
|
527
|
+
* set,
|
|
528
|
+
* HashSet.some((n) => n > 0)
|
|
529
|
+
* ) // true
|
|
530
|
+
*
|
|
531
|
+
* // or piped with the pipe function
|
|
532
|
+
* set.pipe(HashSet.some((n) => n > 0)) // true
|
|
533
|
+
*
|
|
534
|
+
* // or with `data-first` API
|
|
535
|
+
* HashSet.some(set, (n) => n > 0) // true
|
|
536
|
+
* ```
|
|
537
|
+
*
|
|
538
|
+
* @see Other `HashSet` elements are {@link module:HashSet.has} {@link module:HashSet.every} {@link module:HashSet.isSubset}
|
|
53
539
|
*/
|
|
54
540
|
const some = exports.some = HS.some;
|
|
55
541
|
/**
|
|
56
542
|
* Check if a predicate holds true for every `HashSet` element.
|
|
57
543
|
*
|
|
544
|
+
* Time complexity is **`O(n)`** as it needs to traverse the whole HashSet
|
|
545
|
+
* collection
|
|
546
|
+
*
|
|
547
|
+
* @memberof HashSet
|
|
58
548
|
* @since 2.0.0
|
|
59
549
|
* @category elements
|
|
550
|
+
* @example
|
|
551
|
+
*
|
|
552
|
+
* ```ts
|
|
553
|
+
* // Syntax with Refinement
|
|
554
|
+
* import { HashSet, pipe, Predicate } from "effect"
|
|
555
|
+
*
|
|
556
|
+
* const numberOrString = HashSet.make(1, "1", "one", "uno")
|
|
557
|
+
*
|
|
558
|
+
* // with `data-last`, a.k.a. `pipeable` API and `Refinement`
|
|
559
|
+
* pipe(
|
|
560
|
+
* numberOrString, // HashSet.HashSet<number | string>
|
|
561
|
+
* HashSet.every(Predicate.isString)
|
|
562
|
+
* ) // HashSet.HashSet<string>
|
|
563
|
+
*
|
|
564
|
+
* // or piped with the pipe function and `Refinement`
|
|
565
|
+
* numberOrString // HashSet.HashSet<number | string>
|
|
566
|
+
* .pipe(HashSet.every(Predicate.isString)) // HashSet.HashSet<string>
|
|
567
|
+
*
|
|
568
|
+
* // or with `data-first` API and `Refinement`
|
|
569
|
+
* HashSet.every(
|
|
570
|
+
* numberOrString, // HashSet.HashSet<number | string>
|
|
571
|
+
* Predicate.isString
|
|
572
|
+
* ) // HashSet.HashSet<string>
|
|
573
|
+
* ```
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
*
|
|
577
|
+
* ```ts
|
|
578
|
+
* // Syntax with Predicate
|
|
579
|
+
* import { HashSet, pipe } from "effect"
|
|
580
|
+
*
|
|
581
|
+
* const set = HashSet.make(1, 2, 3)
|
|
582
|
+
*
|
|
583
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
584
|
+
* pipe(
|
|
585
|
+
* set,
|
|
586
|
+
* HashSet.every((n) => n >= 0)
|
|
587
|
+
* ) // true
|
|
588
|
+
*
|
|
589
|
+
* // or piped with the pipe function
|
|
590
|
+
* set.pipe(HashSet.every((n) => n >= 0)) // true
|
|
591
|
+
*
|
|
592
|
+
* // or with `data-first` API
|
|
593
|
+
* HashSet.every(set, (n) => n >= 0) // true
|
|
594
|
+
* ```
|
|
595
|
+
*
|
|
596
|
+
* @returns A boolean once it has evaluated that whole collection fulfill the
|
|
597
|
+
* Predicate function
|
|
598
|
+
* @see Other `HashSet` elements are {@link module:HashSet.has} {@link module:HashSet.some} {@link module:HashSet.isSubset}
|
|
60
599
|
*/
|
|
61
600
|
const every = exports.every = HS.every;
|
|
62
601
|
/**
|
|
@@ -65,90 +604,401 @@ const every = exports.every = HS.every;
|
|
|
65
604
|
*
|
|
66
605
|
* **NOTE**: the hash and equal of both sets must be the same.
|
|
67
606
|
*
|
|
607
|
+
* Time complexity analysis is of **`O(n)`**
|
|
608
|
+
*
|
|
609
|
+
* @memberof HashSet
|
|
68
610
|
* @since 2.0.0
|
|
69
611
|
* @category elements
|
|
612
|
+
* @example
|
|
613
|
+
*
|
|
614
|
+
* ```ts
|
|
615
|
+
* // Syntax
|
|
616
|
+
* import { HashSet, pipe } from "effect"
|
|
617
|
+
*
|
|
618
|
+
* const set1 = HashSet.make(0, 1)
|
|
619
|
+
* const set2 = HashSet.make(1, 2)
|
|
620
|
+
* const set3 = HashSet.make(0, 1, 2)
|
|
621
|
+
*
|
|
622
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
623
|
+
* pipe(set1, HashSet.isSubset(set2)) // false
|
|
624
|
+
* pipe(set1, HashSet.isSubset(set3)) // true
|
|
625
|
+
*
|
|
626
|
+
* // or piped with the pipe function
|
|
627
|
+
* set1.pipe(HashSet.isSubset(set2)) // false
|
|
628
|
+
* set1.pipe(HashSet.isSubset(set3)) // true
|
|
629
|
+
*
|
|
630
|
+
* // or with `data-first` API
|
|
631
|
+
* HashSet.isSubset(set1, set2) // false
|
|
632
|
+
* HashSet.isSubset(set1, set3) // true)
|
|
633
|
+
* ```
|
|
634
|
+
*
|
|
635
|
+
* @see Other `HashSet` elements are {@link module:HashSet.has} {@link module:HashSet.some} {@link module:HashSet.every}
|
|
70
636
|
*/
|
|
71
637
|
const isSubset = exports.isSubset = HS.isSubset;
|
|
72
638
|
/**
|
|
73
639
|
* Returns an `IterableIterator` of the values in the `HashSet`.
|
|
74
640
|
*
|
|
641
|
+
* Time complexity: **`O(1)`**
|
|
642
|
+
*
|
|
643
|
+
* @memberof HashSet
|
|
75
644
|
* @since 2.0.0
|
|
76
645
|
* @category getters
|
|
646
|
+
* @example
|
|
647
|
+
*
|
|
648
|
+
* ```ts
|
|
649
|
+
* import { HashSet, pipe } from "effect"
|
|
650
|
+
*
|
|
651
|
+
* const numberIterable = pipe(
|
|
652
|
+
* HashSet.make(0, 1, 1, 2), // HashSet.HashSet<number>
|
|
653
|
+
* HashSet.values // takes an HashSet<A> and returns an IterableIterator<A>
|
|
654
|
+
* )
|
|
655
|
+
*
|
|
656
|
+
* for (const number of numberIterable) {
|
|
657
|
+
* console.log(number) // it will logs: 0, 1, 2
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @see Other `HashSet` getters are {@link module:HashSet.toValues} {@link module:HashSet.size}
|
|
77
662
|
*/
|
|
78
663
|
const values = exports.values = HS.values;
|
|
79
664
|
/**
|
|
80
665
|
* Returns an `Array` of the values within the `HashSet`.
|
|
81
666
|
*
|
|
667
|
+
* Time complexity: **`O(n)`** where n is the number of elements in the set
|
|
668
|
+
*
|
|
669
|
+
* @memberof HashSet
|
|
82
670
|
* @since 3.13.0
|
|
83
671
|
* @category getters
|
|
672
|
+
* @example
|
|
673
|
+
*
|
|
674
|
+
* ```ts
|
|
675
|
+
* import { HashSet, pipe } from "effect"
|
|
676
|
+
* import { deepStrictEqual } from "node:assert/strict"
|
|
677
|
+
*
|
|
678
|
+
* deepStrictEqual(
|
|
679
|
+
* pipe(
|
|
680
|
+
* HashSet.make(0, 1, 1, 2), // HashSet<number>
|
|
681
|
+
* HashSet.toValues // takes an HashSet<A> and returns an Array<A>
|
|
682
|
+
* ),
|
|
683
|
+
* Array.of(0, 1, 2)
|
|
684
|
+
* )
|
|
685
|
+
* ```
|
|
686
|
+
*
|
|
687
|
+
* @see Other `HashSet` getters are {@link module:HashSet.values} {@link module:HashSet.size}
|
|
84
688
|
*/
|
|
85
689
|
const toValues = self => Array.from(values(self));
|
|
86
690
|
/**
|
|
87
691
|
* Calculates the number of values in the `HashSet`.
|
|
88
692
|
*
|
|
693
|
+
* Time complexity: **`O(1)`**
|
|
694
|
+
*
|
|
695
|
+
* @memberof HashSet
|
|
89
696
|
* @since 2.0.0
|
|
90
697
|
* @category getters
|
|
698
|
+
* @example
|
|
699
|
+
*
|
|
700
|
+
* ```ts
|
|
701
|
+
* import { HashSet, pipe } from "effect"
|
|
702
|
+
* import assert from "node:assert/strict"
|
|
703
|
+
*
|
|
704
|
+
* assert.deepStrictEqual(pipe(HashSet.empty(), HashSet.size), 0)
|
|
705
|
+
*
|
|
706
|
+
* assert.deepStrictEqual(
|
|
707
|
+
* pipe(HashSet.make(1, 2, 2, 3, 4, 3), HashSet.size),
|
|
708
|
+
* 4
|
|
709
|
+
* )
|
|
710
|
+
* ```
|
|
711
|
+
*
|
|
712
|
+
* @see Other `HashSet` getters are {@link module:HashSet.values} {@link module:HashSet.toValues}
|
|
91
713
|
*/
|
|
92
714
|
exports.toValues = toValues;
|
|
93
715
|
const size = exports.size = HS.size;
|
|
94
716
|
/**
|
|
95
|
-
*
|
|
717
|
+
* Creates a new mutable version of the `HashSet`
|
|
718
|
+
*
|
|
719
|
+
* When a `HashSet` is mutable, operations like {@link add} and {@link remove}
|
|
720
|
+
* modify the data structure in place instead of creating a new one, which is
|
|
721
|
+
* more efficient when performing multiple operations.
|
|
96
722
|
*
|
|
723
|
+
* @memberof HashSet
|
|
97
724
|
* @since 2.0.0
|
|
725
|
+
* @example
|
|
726
|
+
*
|
|
727
|
+
* ```ts
|
|
728
|
+
* import { HashSet } from "effect"
|
|
729
|
+
* import assert from "node:assert/strict"
|
|
730
|
+
*
|
|
731
|
+
* const UPPER_BOUND = 10_000
|
|
732
|
+
*
|
|
733
|
+
* const immutableSet = HashSet.empty<number>().pipe(HashSet.add(0))
|
|
734
|
+
*
|
|
735
|
+
* // Create a mutable version of the immutableSet
|
|
736
|
+
* const mutableSet = HashSet.beginMutation(immutableSet)
|
|
737
|
+
*
|
|
738
|
+
* for (let i = 1; i < UPPER_BOUND; i++) {
|
|
739
|
+
* // Operations now modify the set in place instead of creating new instances
|
|
740
|
+
* // This is more efficient when making multiple changes
|
|
741
|
+
* const pointerToMutableSet = HashSet.add(mutableSet, i)
|
|
742
|
+
*
|
|
743
|
+
* // the two sets have the same identity, hence `add` is mutating mutableSet and not returning a new HashSet instance
|
|
744
|
+
* assert(Object.is(mutableSet, pointerToMutableSet))
|
|
745
|
+
* assert.equal(HashSet.has(mutableSet, i), true) // `i` is in the mutableSet
|
|
746
|
+
* assert.equal(HashSet.has(immutableSet, i), false) // `i` is not in the immutableSet
|
|
747
|
+
* }
|
|
748
|
+
*
|
|
749
|
+
* const next = UPPER_BOUND + 1
|
|
750
|
+
* // When done, mark the set as immutable again
|
|
751
|
+
* HashSet.endMutation(mutableSet).pipe(
|
|
752
|
+
* HashSet.add(next) // since this returns a new HashSet, it will not be logged as part of the mutableSet
|
|
753
|
+
* )
|
|
754
|
+
* assert.equal(HashSet.has(mutableSet, next), false)
|
|
755
|
+
*
|
|
756
|
+
* console.log(HashSet.toValues(immutableSet)) // [0]
|
|
757
|
+
* console.log(HashSet.toValues(mutableSet).sort((a, b) => a - b)) // [0, 1, 2, 3, ...rest]
|
|
758
|
+
* ```
|
|
759
|
+
*
|
|
760
|
+
* @see Other `HashSet` mutations are {@link module:HashSet.add} {@link module:HashSet.remove} {@link module:HashSet.toggle} {@link module:HashSet.endMutation} {@link module:HashSet.mutate}
|
|
98
761
|
*/
|
|
99
762
|
const beginMutation = exports.beginMutation = HS.beginMutation;
|
|
100
763
|
/**
|
|
101
|
-
*
|
|
764
|
+
* Makes the `HashSet` immutable again.
|
|
765
|
+
*
|
|
766
|
+
* After calling `endMutation`, operations like {@link add} and {@link remove}
|
|
767
|
+
* will create new instances of the `HashSet` instead of modifying the existing
|
|
768
|
+
* one.
|
|
102
769
|
*
|
|
770
|
+
* @memberof HashSet
|
|
103
771
|
* @since 2.0.0
|
|
772
|
+
* @example
|
|
773
|
+
*
|
|
774
|
+
* ```ts
|
|
775
|
+
* import { HashSet } from "effect"
|
|
776
|
+
* import assert from "node:assert/strict"
|
|
777
|
+
*
|
|
778
|
+
* // Create a mutable set
|
|
779
|
+
* const mutableSet = HashSet.beginMutation(HashSet.empty<number>())
|
|
780
|
+
*
|
|
781
|
+
* // Add some elements to the mutable set
|
|
782
|
+
* HashSet.add(mutableSet, 1)
|
|
783
|
+
* HashSet.add(mutableSet, 2)
|
|
784
|
+
*
|
|
785
|
+
* // Before endMutation, operations modify the set in place
|
|
786
|
+
* const sameSet = HashSet.add(mutableSet, 3)
|
|
787
|
+
* assert(Object.is(mutableSet, sameSet)) // true - same object reference
|
|
788
|
+
* assert.deepStrictEqual(HashSet.toValues(mutableSet).sort(), [1, 2, 3])
|
|
789
|
+
*
|
|
790
|
+
* // Make the set immutable again
|
|
791
|
+
* const immutableSet = HashSet.endMutation(mutableSet)
|
|
792
|
+
*
|
|
793
|
+
* // endMutation returns the same set instance, now made immutable
|
|
794
|
+
* assert(Object.is(mutableSet, immutableSet)) // true - same object reference
|
|
795
|
+
*
|
|
796
|
+
* // After endMutation, operations create new instances
|
|
797
|
+
* const newSet = HashSet.add(immutableSet, 4)
|
|
798
|
+
* assert(!Object.is(immutableSet, newSet)) // false - different object references
|
|
799
|
+
*
|
|
800
|
+
* // The original set remains unchanged
|
|
801
|
+
* assert.deepStrictEqual(HashSet.toValues(immutableSet).sort(), [1, 2, 3])
|
|
802
|
+
*
|
|
803
|
+
* // The new set contains the added element
|
|
804
|
+
* assert.deepStrictEqual(HashSet.toValues(newSet).sort(), [1, 2, 3, 4])
|
|
805
|
+
* ```
|
|
806
|
+
*
|
|
807
|
+
* @see Other `HashSet` mutations are {@link module:HashSet.add} {@link module:HashSet.remove} {@link module:HashSet.toggle} {@link module:HashSet.beginMutation} {@link module:HashSet.mutate}
|
|
104
808
|
*/
|
|
105
809
|
const endMutation = exports.endMutation = HS.endMutation;
|
|
106
810
|
/**
|
|
107
811
|
* Mutates the `HashSet` within the context of the provided function.
|
|
108
812
|
*
|
|
813
|
+
* You can consider it a functional abstraction on top of the lower-level
|
|
814
|
+
* mutation primitives of {@link module:HashSet.beginMutation} `->` `mutable
|
|
815
|
+
* context` `->` {@link HashSet.endMutation}.
|
|
816
|
+
*
|
|
817
|
+
* @memberof HashSet
|
|
109
818
|
* @since 2.0.0
|
|
819
|
+
* @example
|
|
820
|
+
*
|
|
821
|
+
* ```ts
|
|
822
|
+
* // Syntax
|
|
823
|
+
* import { HashSet, pipe } from "effect"
|
|
824
|
+
*
|
|
825
|
+
* // with data-last, a.k.a. pipeable API
|
|
826
|
+
* pipe(
|
|
827
|
+
* HashSet.make(1, 2, 3),
|
|
828
|
+
* HashSet.mutate((set) => {
|
|
829
|
+
* HashSet.add(set, 4)
|
|
830
|
+
* HashSet.remove(set, 1)
|
|
831
|
+
* })
|
|
832
|
+
* )
|
|
833
|
+
*
|
|
834
|
+
* // or piped with the pipe function
|
|
835
|
+
* HashSet.make(1, 2, 3).pipe(
|
|
836
|
+
* HashSet.mutate((set) => {
|
|
837
|
+
* HashSet.add(set, 4)
|
|
838
|
+
* HashSet.remove(set, 1)
|
|
839
|
+
* })
|
|
840
|
+
* )
|
|
841
|
+
*
|
|
842
|
+
* // or with data-first API
|
|
843
|
+
* HashSet.mutate(HashSet.make(1, 2, 3), (set) => {
|
|
844
|
+
* HashSet.add(set, 4)
|
|
845
|
+
* HashSet.remove(set, 1)
|
|
846
|
+
* })
|
|
847
|
+
* ```
|
|
848
|
+
*
|
|
849
|
+
* @see Other `HashSet` mutations are {@link module:HashSet.add} {@link module:HashSet.remove} {@link module:HashSet.toggle} {@link module:HashSet.beginMutation} {@link module:HashSet.endMutation}
|
|
110
850
|
*/
|
|
111
851
|
const mutate = exports.mutate = HS.mutate;
|
|
112
852
|
/**
|
|
113
853
|
* Adds a value to the `HashSet`.
|
|
114
854
|
*
|
|
855
|
+
* Time complexity: **`O(1)`** average
|
|
856
|
+
*
|
|
857
|
+
* @remarks
|
|
858
|
+
* Remember that a `HashSet` is a collection of unique values, so adding a value
|
|
859
|
+
* that already exists in the `HashSet` will not add a duplicate.
|
|
860
|
+
*
|
|
861
|
+
* Remember that HashSet is an immutable data structure, so the `add` function,
|
|
862
|
+
* like all other functions that modify the HashSet, will return a new HashSet
|
|
863
|
+
* with the added value.
|
|
864
|
+
* @memberof HashSet
|
|
115
865
|
* @since 2.0.0
|
|
866
|
+
* @example
|
|
867
|
+
*
|
|
868
|
+
* ```ts
|
|
869
|
+
* // Syntax
|
|
870
|
+
* import { HashSet, pipe } from "effect"
|
|
871
|
+
*
|
|
872
|
+
* // with data-last, a.k.a. pipeable API
|
|
873
|
+
* pipe(HashSet.empty(), HashSet.add(0), HashSet.add(0))
|
|
874
|
+
*
|
|
875
|
+
* // or piped with the pipe function
|
|
876
|
+
* HashSet.empty().pipe(HashSet.add(0))
|
|
877
|
+
*
|
|
878
|
+
* // or with data-first API
|
|
879
|
+
* HashSet.add(HashSet.empty(), 0)
|
|
880
|
+
* ```
|
|
881
|
+
*
|
|
882
|
+
* @see Other `HashSet` mutations are {@link module:HashSet.remove} {@link module:HashSet.toggle} {@link module:HashSet.beginMutation} {@link module:HashSet.endMutation} {@link module:HashSet.mutate}
|
|
116
883
|
*/
|
|
117
884
|
const add = exports.add = HS.add;
|
|
118
885
|
/**
|
|
119
886
|
* Removes a value from the `HashSet`.
|
|
120
887
|
*
|
|
888
|
+
* Time complexity: **`O(1)`** average
|
|
889
|
+
*
|
|
890
|
+
* @memberof HashSet
|
|
121
891
|
* @since 2.0.0
|
|
892
|
+
* @example
|
|
893
|
+
*
|
|
894
|
+
* ```ts
|
|
895
|
+
* // Syntax
|
|
896
|
+
* import { HashSet, pipe } from "effect"
|
|
897
|
+
*
|
|
898
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
899
|
+
* pipe(HashSet.make(0, 1, 2), HashSet.remove(0))
|
|
900
|
+
*
|
|
901
|
+
* // or piped with the pipe function
|
|
902
|
+
* HashSet.make(0, 1, 2).pipe(HashSet.remove(0))
|
|
903
|
+
*
|
|
904
|
+
* // or with `data-first` API
|
|
905
|
+
* HashSet.remove(HashSet.make(0, 1, 2), 0)
|
|
906
|
+
* ```
|
|
907
|
+
*
|
|
908
|
+
* @see Other `HashSet` mutations are {@link module:HashSet.add} {@link module:HashSet.toggle} {@link module:HashSet.beginMutation} {@link module:HashSet.endMutation} {@link module:HashSet.mutate}
|
|
122
909
|
*/
|
|
123
910
|
const remove = exports.remove = HS.remove;
|
|
124
911
|
/**
|
|
125
|
-
* Computes the set difference between this `HashSet` and the
|
|
126
|
-
* `Iterable<A>`.
|
|
912
|
+
* Computes the set difference `(A - B)` between this `HashSet` and the
|
|
913
|
+
* specified `Iterable<A>`.
|
|
914
|
+
*
|
|
915
|
+
* Time complexity: **`O(n)`** where n is the number of elements in the set
|
|
127
916
|
*
|
|
128
917
|
* **NOTE**: the hash and equal of the values in both the set and the iterable
|
|
129
|
-
* must be the same
|
|
918
|
+
* must be the same; meaning we cannot compute a difference between a `HashSet
|
|
919
|
+
* of bananas` and a `HashSet of elephants` as they are not the same type and
|
|
920
|
+
* won't implement the Equal trait in the same way.
|
|
130
921
|
*
|
|
922
|
+
* @memberof HashSet
|
|
131
923
|
* @since 2.0.0
|
|
924
|
+
* @example
|
|
925
|
+
*
|
|
926
|
+
* ```ts
|
|
927
|
+
* // Syntax
|
|
928
|
+
* import { HashSet, pipe } from "effect"
|
|
929
|
+
*
|
|
930
|
+
* // with data-last, a.k.a. pipeable API
|
|
931
|
+
* pipe(HashSet.make(1, 2, 3), HashSet.difference(HashSet.make(3, 4, 5)))
|
|
932
|
+
*
|
|
933
|
+
* // or piped with the pipe function
|
|
934
|
+
* HashSet.make(1, 2, 3).pipe(HashSet.difference(HashSet.make(3, 4, 5)))
|
|
935
|
+
*
|
|
936
|
+
* // or with data-first API
|
|
937
|
+
* HashSet.difference(HashSet.make(1, 2, 3), HashSet.make(3, 4, 5))
|
|
938
|
+
* ```
|
|
939
|
+
*
|
|
940
|
+
* @see Other `HashSet` operations are {@link module:HashSet.intersection} {@link module:HashSet.union}
|
|
132
941
|
*/
|
|
133
942
|
const difference = exports.difference = HS.difference;
|
|
134
943
|
/**
|
|
135
944
|
* Returns a `HashSet` of values which are present in both this set and that
|
|
136
|
-
* `Iterable<A>`.
|
|
945
|
+
* `Iterable<A>`. Computes set intersection (A ∩ B)
|
|
946
|
+
*
|
|
947
|
+
* Time complexity: **`O(n)`** where n is the number of elements in the smaller
|
|
948
|
+
* set
|
|
137
949
|
*
|
|
138
950
|
* **NOTE**: the hash and equal of the values in both the set and the iterable
|
|
139
951
|
* must be the same.
|
|
140
952
|
*
|
|
953
|
+
* @memberof HashSet
|
|
141
954
|
* @since 2.0.0
|
|
955
|
+
* @example
|
|
956
|
+
*
|
|
957
|
+
* ```ts
|
|
958
|
+
* // Syntax
|
|
959
|
+
* import { HashSet, pipe } from "effect"
|
|
960
|
+
*
|
|
961
|
+
* // with data-last, a.k.a. pipeable API
|
|
962
|
+
* pipe(HashSet.make(1, 2, 3), HashSet.intersection(HashSet.make(2, 3, 4)))
|
|
963
|
+
*
|
|
964
|
+
* // or piped with the pipe function
|
|
965
|
+
* HashSet.make(1, 2, 3).pipe(HashSet.intersection(HashSet.make(2, 3, 4)))
|
|
966
|
+
*
|
|
967
|
+
* // or with data-first API
|
|
968
|
+
* HashSet.intersection(HashSet.make(1, 2, 3), HashSet.make(2, 3, 4))
|
|
969
|
+
* ```
|
|
970
|
+
*
|
|
971
|
+
* @see Other `HashSet` operations are {@link module:HashSet.difference} {@link module:HashSet.union}
|
|
142
972
|
*/
|
|
143
973
|
const intersection = exports.intersection = HS.intersection;
|
|
144
974
|
/**
|
|
145
|
-
* Computes the set union `(
|
|
975
|
+
* Computes the set union `( self ∪ that )` between this `HashSet` and the
|
|
146
976
|
* specified `Iterable<A>`.
|
|
147
977
|
*
|
|
978
|
+
* Time complexity: **`O(n)`** where n is the number of elements in the set
|
|
979
|
+
*
|
|
148
980
|
* **NOTE**: the hash and equal of the values in both the set and the iterable
|
|
149
981
|
* must be the same.
|
|
150
982
|
*
|
|
983
|
+
* @memberof HashSet
|
|
151
984
|
* @since 2.0.0
|
|
985
|
+
* @example
|
|
986
|
+
*
|
|
987
|
+
* ```ts
|
|
988
|
+
* // Syntax
|
|
989
|
+
* import { HashSet, pipe } from "effect"
|
|
990
|
+
*
|
|
991
|
+
* // with data-last, a.k.a. pipeable API
|
|
992
|
+
* pipe(HashSet.make(1, 2, 3), HashSet.union(HashSet.make(3, 4, 5)))
|
|
993
|
+
*
|
|
994
|
+
* // or piped with the pipe function
|
|
995
|
+
* HashSet.make(1, 2, 3).pipe(HashSet.union(HashSet.make(3, 4, 5)))
|
|
996
|
+
*
|
|
997
|
+
* // or with data-first API
|
|
998
|
+
* HashSet.union(HashSet.make(1, 2, 3), HashSet.make(3, 4, 5))
|
|
999
|
+
* ```
|
|
1000
|
+
*
|
|
1001
|
+
* @see Other `HashSet` operations are {@link module:HashSet.difference} {@link module:HashSet.intersection}
|
|
152
1002
|
*/
|
|
153
1003
|
const union = exports.union = HS.union;
|
|
154
1004
|
/**
|
|
@@ -156,42 +1006,196 @@ const union = exports.union = HS.union;
|
|
|
156
1006
|
* will be removed from the `HashSet`, otherwise the value will be added to the
|
|
157
1007
|
* `HashSet`.
|
|
158
1008
|
*
|
|
1009
|
+
* Time complexity: **`O(1)`** average
|
|
1010
|
+
*
|
|
1011
|
+
* @memberof HashSet
|
|
159
1012
|
* @since 2.0.0
|
|
1013
|
+
* @example
|
|
1014
|
+
*
|
|
1015
|
+
* ```ts
|
|
1016
|
+
* // Syntax
|
|
1017
|
+
* import { HashSet, pipe } from "effect"
|
|
1018
|
+
*
|
|
1019
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1020
|
+
* pipe(HashSet.make(0, 1, 2), HashSet.toggle(0))
|
|
1021
|
+
*
|
|
1022
|
+
* // or piped with the pipe function
|
|
1023
|
+
* HashSet.make(0, 1, 2).pipe(HashSet.toggle(0))
|
|
1024
|
+
*
|
|
1025
|
+
* // or with `data-first` API
|
|
1026
|
+
* HashSet.toggle(HashSet.make(0, 1, 2), 0)
|
|
1027
|
+
* ```
|
|
1028
|
+
*
|
|
1029
|
+
* @returns A new `HashSet` where the toggled value is being either added or
|
|
1030
|
+
* removed based on the initial `HashSet` state.
|
|
1031
|
+
* @see Other `HashSet` mutations are {@link module:HashSet.add} {@link module:HashSet.remove} {@link module:HashSet.beginMutation} {@link module:HashSet.endMutation} {@link module:HashSet.mutate}
|
|
160
1032
|
*/
|
|
161
1033
|
const toggle = exports.toggle = HS.toggle;
|
|
162
1034
|
/**
|
|
163
1035
|
* Maps over the values of the `HashSet` using the specified function.
|
|
164
1036
|
*
|
|
1037
|
+
* The time complexity is of **`O(n)`**.
|
|
1038
|
+
*
|
|
1039
|
+
* @memberof HashSet
|
|
165
1040
|
* @since 2.0.0
|
|
166
1041
|
* @category mapping
|
|
1042
|
+
* @example
|
|
1043
|
+
*
|
|
1044
|
+
* ```ts
|
|
1045
|
+
* // Syntax
|
|
1046
|
+
* import { HashSet, pipe } from "effect"
|
|
1047
|
+
*
|
|
1048
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1049
|
+
* pipe(
|
|
1050
|
+
* HashSet.make(0, 1, 2), // HashSet.HashSet<number>
|
|
1051
|
+
* HashSet.map(String) // HashSet.HashSet<string>
|
|
1052
|
+
* )
|
|
1053
|
+
*
|
|
1054
|
+
* // or piped with the pipe method
|
|
1055
|
+
* HashSet.make(0, 1, 2).pipe(HashSet.map(String))
|
|
1056
|
+
*
|
|
1057
|
+
* // or with `data-first` API
|
|
1058
|
+
* HashSet.map(HashSet.make(0, 1, 2), String)
|
|
1059
|
+
* ```
|
|
167
1060
|
*/
|
|
168
1061
|
const map = exports.map = HS.map;
|
|
169
1062
|
/**
|
|
170
1063
|
* Chains over the values of the `HashSet` using the specified function.
|
|
171
1064
|
*
|
|
1065
|
+
* The time complexity is of **`O(n)`**.
|
|
1066
|
+
*
|
|
1067
|
+
* @memberof HashSet
|
|
172
1068
|
* @since 2.0.0
|
|
173
1069
|
* @category sequencing
|
|
1070
|
+
* @example
|
|
1071
|
+
*
|
|
1072
|
+
* ```ts
|
|
1073
|
+
* // Syntax
|
|
1074
|
+
* import { HashSet, pipe } from "effect"
|
|
1075
|
+
*
|
|
1076
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1077
|
+
* pipe(
|
|
1078
|
+
* HashSet.make(0, 1, 2), // HashSet.HashSet<number>
|
|
1079
|
+
* HashSet.flatMap((n) => Array.of(String(n))) // HashSet.HashSet<string>
|
|
1080
|
+
* )
|
|
1081
|
+
*
|
|
1082
|
+
* // or piped with the pipe method
|
|
1083
|
+
* HashSet.make(0, 1, 2) // HashSet.HashSet<number>
|
|
1084
|
+
* .pipe(
|
|
1085
|
+
* HashSet.flatMap((n) => Array.of(String(n))) // HashSet.HashSet<string>
|
|
1086
|
+
* )
|
|
1087
|
+
*
|
|
1088
|
+
* // or with `data-first` API
|
|
1089
|
+
* HashSet.flatMap(HashSet.make(0, 1, 2), (n) => Array.of(String(n)))
|
|
1090
|
+
* ```
|
|
174
1091
|
*/
|
|
175
1092
|
const flatMap = exports.flatMap = HS.flatMap;
|
|
176
1093
|
/**
|
|
177
1094
|
* Applies the specified function to the values of the `HashSet`.
|
|
178
1095
|
*
|
|
1096
|
+
* The time complexity is of **`O(n)`**.
|
|
1097
|
+
*
|
|
1098
|
+
* @memberof HashSet
|
|
179
1099
|
* @since 2.0.0
|
|
180
1100
|
* @category traversing
|
|
1101
|
+
* @example
|
|
1102
|
+
*
|
|
1103
|
+
* ```ts
|
|
1104
|
+
* // Syntax
|
|
1105
|
+
* import { HashSet, pipe } from "effect"
|
|
1106
|
+
*
|
|
1107
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1108
|
+
* pipe(HashSet.make(0, 1, 2), HashSet.forEach(console.log)) // logs: 0 1 2
|
|
1109
|
+
*
|
|
1110
|
+
* // or piped with the pipe method
|
|
1111
|
+
* HashSet.make(0, 1, 2).pipe(HashSet.forEach(console.log)) // logs: 0 1 2
|
|
1112
|
+
*
|
|
1113
|
+
* // or with `data-first` API
|
|
1114
|
+
* HashSet.forEach(HashSet.make(0, 1, 2), console.log) // logs: 0 1 2
|
|
1115
|
+
* ```
|
|
181
1116
|
*/
|
|
182
1117
|
const forEach = exports.forEach = HS.forEach;
|
|
183
1118
|
/**
|
|
184
1119
|
* Reduces the specified state over the values of the `HashSet`.
|
|
185
1120
|
*
|
|
1121
|
+
* The time complexity is of **`O(n)`**.
|
|
1122
|
+
*
|
|
1123
|
+
* @memberof HashSet
|
|
186
1124
|
* @since 2.0.0
|
|
187
1125
|
* @category folding
|
|
1126
|
+
* @example
|
|
1127
|
+
*
|
|
1128
|
+
* ```ts
|
|
1129
|
+
* // Syntax
|
|
1130
|
+
* import { HashSet, pipe } from "effect"
|
|
1131
|
+
*
|
|
1132
|
+
* const sum = (a: number, b: number): number => a + b
|
|
1133
|
+
*
|
|
1134
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1135
|
+
* pipe(HashSet.make(0, 1, 2), HashSet.reduce(0, sum))
|
|
1136
|
+
*
|
|
1137
|
+
* // or with the pipe method
|
|
1138
|
+
* HashSet.make(0, 1, 2).pipe(HashSet.reduce(0, sum))
|
|
1139
|
+
*
|
|
1140
|
+
* // or with `data-first` API
|
|
1141
|
+
* HashSet.reduce(HashSet.make(0, 1, 2), 0, sum)
|
|
1142
|
+
* ```
|
|
188
1143
|
*/
|
|
189
1144
|
const reduce = exports.reduce = HS.reduce;
|
|
190
1145
|
/**
|
|
191
1146
|
* Filters values out of a `HashSet` using the specified predicate.
|
|
192
1147
|
*
|
|
1148
|
+
* The time complexity is of **`O(n)`**.
|
|
1149
|
+
*
|
|
1150
|
+
* @memberof HashSet
|
|
193
1151
|
* @since 2.0.0
|
|
194
1152
|
* @category filtering
|
|
1153
|
+
* @example
|
|
1154
|
+
*
|
|
1155
|
+
* ```ts
|
|
1156
|
+
* // Syntax with Predicate
|
|
1157
|
+
* import { HashSet, type Predicate, pipe } from "effect"
|
|
1158
|
+
*
|
|
1159
|
+
* const filterPositiveNumbers: Predicate.Predicate<number> = (n) => n > 0
|
|
1160
|
+
*
|
|
1161
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1162
|
+
* pipe(
|
|
1163
|
+
* HashSet.make(-2, -1, 0, 1, 2),
|
|
1164
|
+
* HashSet.filter(filterPositiveNumbers)
|
|
1165
|
+
* )
|
|
1166
|
+
*
|
|
1167
|
+
* // or with the pipe method
|
|
1168
|
+
* HashSet.make(-2, -1, 0, 1, 2).pipe(HashSet.filter(filterPositiveNumbers))
|
|
1169
|
+
*
|
|
1170
|
+
* // or with `data-first` API
|
|
1171
|
+
* HashSet.filter(HashSet.make(-2, -1, 0, 1, 2), filterPositiveNumbers)
|
|
1172
|
+
* ```
|
|
1173
|
+
*
|
|
1174
|
+
* @example
|
|
1175
|
+
*
|
|
1176
|
+
* ```ts
|
|
1177
|
+
* /// Syntax with Refinement
|
|
1178
|
+
* import { HashSet, pipe } from "effect"
|
|
1179
|
+
*
|
|
1180
|
+
* const stringRefinement = (value: unknown): value is string =>
|
|
1181
|
+
* typeof value === "string"
|
|
1182
|
+
*
|
|
1183
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1184
|
+
* pipe(
|
|
1185
|
+
* HashSet.make(1, "unos", 2, "two", 3, "trois", 4, "vier"), // // HashSet.HashSet<number | string>
|
|
1186
|
+
* HashSet.filter(stringRefinement)
|
|
1187
|
+
* ) // HashSet.HashSet<string>
|
|
1188
|
+
*
|
|
1189
|
+
* // or with the pipe method
|
|
1190
|
+
* HashSet.make(1, "unos", 2, "two", 3, "trois", 4, "vier") // HashSet.HashSet<number | string>
|
|
1191
|
+
* .pipe(HashSet.filter(stringRefinement)) // HashSet.HashSet<string>
|
|
1192
|
+
*
|
|
1193
|
+
* // or with `data-first` API
|
|
1194
|
+
* HashSet.filter(
|
|
1195
|
+
* HashSet.make(1, "unos", 2, "two", 3, "trois", 4, "vier"), // HashSet.HashSet<number | string>
|
|
1196
|
+
* stringRefinement
|
|
1197
|
+
* ) // HashSet.HashSet<string>
|
|
1198
|
+
* ```
|
|
195
1199
|
*/
|
|
196
1200
|
const filter = exports.filter = HS.filter;
|
|
197
1201
|
/**
|
|
@@ -201,8 +1205,59 @@ const filter = exports.filter = HS.filter;
|
|
|
201
1205
|
* right side of the resulting `Tuple`, otherwise the value will be placed into
|
|
202
1206
|
* the left side.
|
|
203
1207
|
*
|
|
1208
|
+
* Time complexity is of **`O(n)`**.
|
|
1209
|
+
*
|
|
1210
|
+
* @memberof HashSet
|
|
204
1211
|
* @since 2.0.0
|
|
205
1212
|
* @category partitioning
|
|
1213
|
+
* @example
|
|
1214
|
+
*
|
|
1215
|
+
* ```ts
|
|
1216
|
+
* // Syntax with Predicate
|
|
1217
|
+
* import { HashSet, pipe, Predicate } from "effect"
|
|
1218
|
+
*
|
|
1219
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1220
|
+
* pipe(
|
|
1221
|
+
* HashSet.make(0, 1, 2, 3, 4, 5),
|
|
1222
|
+
* HashSet.partition((n) => n % 2 === 0)
|
|
1223
|
+
* )
|
|
1224
|
+
*
|
|
1225
|
+
* // or with the pipe method
|
|
1226
|
+
* HashSet.make(0, 1, 2, 3, 4, 5).pipe(
|
|
1227
|
+
* HashSet.partition((n) => n % 2 === 0)
|
|
1228
|
+
* )
|
|
1229
|
+
*
|
|
1230
|
+
* // or with `data-first` API
|
|
1231
|
+
* HashSet.partition(HashSet.make(0, 1, 2, 3, 4, 5), (n) => n % 2 === 0)
|
|
1232
|
+
* ```
|
|
1233
|
+
*
|
|
1234
|
+
* @example
|
|
1235
|
+
*
|
|
1236
|
+
* ```ts
|
|
1237
|
+
* // Syntax with Refinement
|
|
1238
|
+
* import { HashSet, pipe, Predicate } from "effect"
|
|
1239
|
+
*
|
|
1240
|
+
* const stringRefinement: Predicate.Refinement<string | number, string> = (
|
|
1241
|
+
* value
|
|
1242
|
+
* ) => typeof value === "string"
|
|
1243
|
+
*
|
|
1244
|
+
* // with `data-last`, a.k.a. `pipeable` API
|
|
1245
|
+
* pipe(
|
|
1246
|
+
* HashSet.make(1, "unos", 2, "two", 3, "trois", 4, "vier"),
|
|
1247
|
+
* HashSet.partition(stringRefinement)
|
|
1248
|
+
* )
|
|
1249
|
+
*
|
|
1250
|
+
* // or with the pipe method
|
|
1251
|
+
* HashSet.make(1, "unos", 2, "two", 3, "trois", 4, "vier").pipe(
|
|
1252
|
+
* HashSet.partition(stringRefinement)
|
|
1253
|
+
* )
|
|
1254
|
+
*
|
|
1255
|
+
* // or with `data-first` API
|
|
1256
|
+
* HashSet.partition(
|
|
1257
|
+
* HashSet.make(1, "unos", 2, "two", 3, "trois", 4, "vier"),
|
|
1258
|
+
* stringRefinement
|
|
1259
|
+
* )
|
|
1260
|
+
* ```
|
|
206
1261
|
*/
|
|
207
1262
|
const partition = exports.partition = HS.partition;
|
|
208
1263
|
//# sourceMappingURL=HashSet.js.map
|