effect 3.14.3 → 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/HashSet.js +111 -87
- package/dist/cjs/HashSet.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/HashSet.d.ts +149 -106
- package/dist/dts/HashSet.d.ts.map +1 -1
- package/dist/dts/index.d.ts +40 -40
- package/dist/esm/HashSet.js +111 -87
- package/dist/esm/HashSet.js.map +1 -1
- package/dist/esm/index.js +40 -40
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/HashSet.ts +149 -106
- package/src/index.ts +40 -40
- package/src/internal/version.ts +1 -1
package/src/HashSet.ts
CHANGED
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
*
|
|
34
34
|
* ## Performance Characteristics
|
|
35
35
|
*
|
|
36
|
-
* - **Lookup** operations ({@
|
|
36
|
+
* - **Lookup** operations ({@link module:HashSet.has}): **`O(1)`** average time
|
|
37
37
|
* complexity
|
|
38
|
-
* - **Insertion** operations ({@
|
|
38
|
+
* - **Insertion** operations ({@link module:HashSet.add}): **`O(1)`** average time
|
|
39
39
|
* complexity
|
|
40
|
-
* - **Removal** operations ({@
|
|
41
|
-
* complexity
|
|
42
|
-
* - **Set** operations ({@
|
|
43
|
-
* {@
|
|
40
|
+
* - **Removal** operations ({@link module:HashSet.remove}): **`O(1)`** average
|
|
41
|
+
* time complexity
|
|
42
|
+
* - **Set** operations ({@link module:HashSet.union},
|
|
43
|
+
* {@link module:HashSet.intersection}): **`O(n)`** where n is the size of the
|
|
44
44
|
* smaller set
|
|
45
45
|
* - **Iteration**: **`O(n)`** where n is the size of the set
|
|
46
46
|
*
|
|
@@ -53,40 +53,40 @@
|
|
|
53
53
|
*
|
|
54
54
|
* ## Operations Reference
|
|
55
55
|
*
|
|
56
|
-
* | Category | Operation
|
|
57
|
-
* | ------------ |
|
|
58
|
-
* | constructors | {@
|
|
59
|
-
* | constructors | {@
|
|
60
|
-
* | constructors | {@
|
|
61
|
-
* | |
|
|
62
|
-
* | elements | {@
|
|
63
|
-
* | elements | {@
|
|
64
|
-
* | elements | {@
|
|
65
|
-
* | elements | {@
|
|
66
|
-
* | |
|
|
67
|
-
* | getters | {@
|
|
68
|
-
* | getters | {@
|
|
69
|
-
* | getters | {@
|
|
70
|
-
* | |
|
|
71
|
-
* | mutations | {@
|
|
72
|
-
* | mutations | {@
|
|
73
|
-
* | mutations | {@
|
|
74
|
-
* | |
|
|
75
|
-
* | operations | {@
|
|
76
|
-
* | operations | {@
|
|
77
|
-
* | operations | {@
|
|
78
|
-
* | |
|
|
79
|
-
* | mapping | {@
|
|
80
|
-
* | |
|
|
81
|
-
* | sequencing | {@
|
|
82
|
-
* | |
|
|
83
|
-
* | traversing | {@
|
|
84
|
-
* | |
|
|
85
|
-
* | folding | {@
|
|
86
|
-
* | |
|
|
87
|
-
* | filtering | {@
|
|
88
|
-
* | |
|
|
89
|
-
* | partitioning | {@
|
|
56
|
+
* | Category | Operation | Description | Complexity |
|
|
57
|
+
* | ------------ | ----------------------------------- | ------------------------------------------- | ---------- |
|
|
58
|
+
* | constructors | {@link module:HashSet.empty} | Creates an empty HashSet | O(1) |
|
|
59
|
+
* | constructors | {@link module:HashSet.fromIterable} | Creates a HashSet from an iterable | O(n) |
|
|
60
|
+
* | constructors | {@link module:HashSet.make} | Creates a HashSet from multiple values | O(n) |
|
|
61
|
+
* | | | | |
|
|
62
|
+
* | elements | {@link module:HashSet.has} | Checks if a value exists in the set | O(1) avg |
|
|
63
|
+
* | elements | {@link module:HashSet.some} | Checks if any element satisfies a predicate | O(n) |
|
|
64
|
+
* | elements | {@link module:HashSet.every} | Checks if all elements satisfy a predicate | O(n) |
|
|
65
|
+
* | elements | {@link module:HashSet.isSubset} | Checks if a set is a subset of another | O(n) |
|
|
66
|
+
* | | | | |
|
|
67
|
+
* | getters | {@link module:HashSet.values} | Gets an iterator of all values | O(1) |
|
|
68
|
+
* | getters | {@link module:HashSet.toValues} | Gets an array of all values | O(n) |
|
|
69
|
+
* | getters | {@link module:HashSet.size} | Gets the number of elements | O(1) |
|
|
70
|
+
* | | | | |
|
|
71
|
+
* | mutations | {@link module:HashSet.add} | Adds a value to the set | O(1) avg |
|
|
72
|
+
* | mutations | {@link module:HashSet.remove} | Removes a value from the set | O(1) avg |
|
|
73
|
+
* | mutations | {@link module:HashSet.toggle} | Toggles a value's presence | O(1) avg |
|
|
74
|
+
* | | | | |
|
|
75
|
+
* | operations | {@link module:HashSet.difference} | Computes set difference (A - B) | O(n) |
|
|
76
|
+
* | operations | {@link module:HashSet.intersection} | Computes set intersection (A ∩ B) | O(n) |
|
|
77
|
+
* | operations | {@link module:HashSet.union} | Computes set union (A ∪ B) | O(n) |
|
|
78
|
+
* | | | | |
|
|
79
|
+
* | mapping | {@link module:HashSet.map} | Transforms each element | O(n) |
|
|
80
|
+
* | | | | |
|
|
81
|
+
* | sequencing | {@link module:HashSet.flatMap} | Transforms and flattens elements | O(n) |
|
|
82
|
+
* | | | | |
|
|
83
|
+
* | traversing | {@link module:HashSet.forEach} | Applies a function to each element | O(n) |
|
|
84
|
+
* | | | | |
|
|
85
|
+
* | folding | {@link module:HashSet.reduce} | Reduces the set to a single value | O(n) |
|
|
86
|
+
* | | | | |
|
|
87
|
+
* | filtering | {@link module:HashSet.filter} | Keeps elements that satisfy a predicate | O(n) |
|
|
88
|
+
* | | | | |
|
|
89
|
+
* | partitioning | {@link module:HashSet.partition} | Splits into two sets by a predicate | O(n) |
|
|
90
90
|
*
|
|
91
91
|
* ## Notes
|
|
92
92
|
*
|
|
@@ -271,9 +271,10 @@ export type TypeId = typeof TypeId
|
|
|
271
271
|
* @memberof HashSet
|
|
272
272
|
* @since 2.0.0
|
|
273
273
|
* @category models
|
|
274
|
-
* @example
|
|
274
|
+
* @example
|
|
275
275
|
*
|
|
276
276
|
* ```ts
|
|
277
|
+
* // Syntax
|
|
277
278
|
* import { HashSet } from "effect"
|
|
278
279
|
*
|
|
279
280
|
* let numberSet: HashSet.HashSet<number>
|
|
@@ -369,7 +370,7 @@ export const isHashSet: {
|
|
|
369
370
|
* ) // Output: [1, 2]
|
|
370
371
|
* ```
|
|
371
372
|
*
|
|
372
|
-
* @see Other `HashSet` constructors are {@link make} {@link fromIterable}
|
|
373
|
+
* @see Other `HashSet` constructors are {@link module:HashSet.make} {@link module:HashSet.fromIterable}
|
|
373
374
|
*/
|
|
374
375
|
export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
375
376
|
|
|
@@ -381,9 +382,10 @@ export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
|
381
382
|
* @memberof HashSet
|
|
382
383
|
* @since 2.0.0
|
|
383
384
|
* @category constructors
|
|
384
|
-
* @example
|
|
385
|
+
* @example
|
|
385
386
|
*
|
|
386
387
|
* ```ts
|
|
388
|
+
* // Creating a HashSet from an Array
|
|
387
389
|
* import { HashSet, pipe } from "effect"
|
|
388
390
|
*
|
|
389
391
|
* console.log(
|
|
@@ -395,9 +397,10 @@ export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
|
395
397
|
* ) // Output: [1, 2, 3, 4, 5]
|
|
396
398
|
* ```
|
|
397
399
|
*
|
|
398
|
-
* @example
|
|
400
|
+
* @example
|
|
399
401
|
*
|
|
400
402
|
* ```ts
|
|
403
|
+
* // Creating a HashSet from a Set
|
|
401
404
|
* import { HashSet, pipe } from "effect"
|
|
402
405
|
*
|
|
403
406
|
* console.log(
|
|
@@ -409,9 +412,10 @@ export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
|
409
412
|
* ) // Output: ["apple", "banana", "orange"]
|
|
410
413
|
* ```
|
|
411
414
|
*
|
|
412
|
-
* @example
|
|
415
|
+
* @example
|
|
413
416
|
*
|
|
414
417
|
* ```ts
|
|
418
|
+
* // Creating a HashSet from a Generator
|
|
415
419
|
* import { HashSet } from "effect"
|
|
416
420
|
*
|
|
417
421
|
* // Generator functions return iterables
|
|
@@ -430,9 +434,10 @@ export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
|
430
434
|
* // Outputs: [0, 1, 2, 3, 5, 8, 13, 21, 34] but in unsorted order
|
|
431
435
|
* ```
|
|
432
436
|
*
|
|
433
|
-
* @example
|
|
437
|
+
* @example
|
|
434
438
|
*
|
|
435
439
|
* ```ts
|
|
440
|
+
* // Creating a HashSet from another HashSet
|
|
436
441
|
* import { HashSet, pipe } from "effect"
|
|
437
442
|
*
|
|
438
443
|
* console.log(
|
|
@@ -445,10 +450,10 @@ export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
|
445
450
|
* ) // Output: [1, 2, 3, 4]
|
|
446
451
|
* ```
|
|
447
452
|
*
|
|
448
|
-
* @example
|
|
449
|
-
* {@link Chunk}
|
|
453
|
+
* @example
|
|
450
454
|
*
|
|
451
455
|
* ```ts
|
|
456
|
+
* // Creating a HashSet from other Effect's data structures like Chunk
|
|
452
457
|
* import { Chunk, HashSet, pipe } from "effect"
|
|
453
458
|
*
|
|
454
459
|
* console.log(
|
|
@@ -460,7 +465,7 @@ export const empty: <A = never>() => HashSet<A> = HS.empty
|
|
|
460
465
|
* ) // Outputs: [1, 2, 3, 4]
|
|
461
466
|
* ```
|
|
462
467
|
*
|
|
463
|
-
* @see Other `HashSet` constructors are {@link empty} {@link make}
|
|
468
|
+
* @see Other `HashSet` constructors are {@link module:HashSet.empty} {@link module:HashSet.make}
|
|
464
469
|
*/
|
|
465
470
|
export const fromIterable: <A>(elements: Iterable<A>) => HashSet<A> = HS.fromIterable
|
|
466
471
|
|
|
@@ -549,7 +554,7 @@ export const fromIterable: <A>(elements: Iterable<A>) => HashSet<A> = HS.fromIte
|
|
|
549
554
|
* )
|
|
550
555
|
* ```
|
|
551
556
|
*
|
|
552
|
-
* @see Other `HashSet` constructors are {@
|
|
557
|
+
* @see Other `HashSet` constructors are {@link module:HashSet.fromIterable} {@link module:HashSet.empty}
|
|
553
558
|
*/
|
|
554
559
|
export const make: <As extends ReadonlyArray<any>>(...elements: As) => HashSet<As[number]> = HS.make
|
|
555
560
|
|
|
@@ -561,9 +566,10 @@ export const make: <As extends ReadonlyArray<any>>(...elements: As) => HashSet<A
|
|
|
561
566
|
* @memberof HashSet
|
|
562
567
|
* @since 2.0.0
|
|
563
568
|
* @category elements
|
|
564
|
-
* @example
|
|
569
|
+
* @example
|
|
565
570
|
*
|
|
566
571
|
* ```ts
|
|
572
|
+
* // Syntax
|
|
567
573
|
* import { HashSet, pipe } from "effect"
|
|
568
574
|
*
|
|
569
575
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -577,13 +583,14 @@ export const make: <As extends ReadonlyArray<any>>(...elements: As) => HashSet<A
|
|
|
577
583
|
* ```
|
|
578
584
|
*
|
|
579
585
|
* @returns A `boolean` signaling the presence of the value in the HashSet
|
|
580
|
-
* @see Other `HashSet` elements are {@link some} {@link every} {@link isSubset}
|
|
586
|
+
* @see Other `HashSet` elements are {@link module:HashSet.some} {@link module:HashSet.every} {@link module:HashSet.isSubset}
|
|
581
587
|
*/
|
|
582
588
|
export const has: {
|
|
583
589
|
/**
|
|
584
|
-
* @example
|
|
590
|
+
* @example
|
|
585
591
|
*
|
|
586
592
|
* ```ts
|
|
593
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
587
594
|
* import * as assert from "node:assert/strict"
|
|
588
595
|
* import { HashSet, pipe } from "effect"
|
|
589
596
|
*
|
|
@@ -598,9 +605,10 @@ export const has: {
|
|
|
598
605
|
<A>(value: A): (self: HashSet<A>) => boolean
|
|
599
606
|
|
|
600
607
|
/**
|
|
601
|
-
* @example
|
|
608
|
+
* @example
|
|
602
609
|
*
|
|
603
610
|
* ```ts
|
|
611
|
+
* // `data-first` API
|
|
604
612
|
* import * as assert from "node:assert/strict"
|
|
605
613
|
* import { HashSet, pipe } from "effect"
|
|
606
614
|
*
|
|
@@ -623,9 +631,10 @@ export const has: {
|
|
|
623
631
|
* @memberof HashSet
|
|
624
632
|
* @since 2.0.0
|
|
625
633
|
* @category elements
|
|
626
|
-
* @example
|
|
634
|
+
* @example
|
|
627
635
|
*
|
|
628
636
|
* ```ts
|
|
637
|
+
* // Syntax
|
|
629
638
|
* import { HashSet, pipe } from "effect"
|
|
630
639
|
*
|
|
631
640
|
* const set: HashSet.HashSet<number> = HashSet.make(0, 1, 2)
|
|
@@ -643,13 +652,14 @@ export const has: {
|
|
|
643
652
|
* HashSet.some(set, (n) => n > 0) // true
|
|
644
653
|
* ```
|
|
645
654
|
*
|
|
646
|
-
* @see Other `HashSet` elements are {@link has} {@link every} {@link isSubset}
|
|
655
|
+
* @see Other `HashSet` elements are {@link module:HashSet.has} {@link module:HashSet.every} {@link module:HashSet.isSubset}
|
|
647
656
|
*/
|
|
648
657
|
export const some: {
|
|
649
658
|
/**
|
|
650
|
-
* @example
|
|
659
|
+
* @example
|
|
651
660
|
*
|
|
652
661
|
* ```ts
|
|
662
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
653
663
|
* import * as assert from "node:assert/strict"
|
|
654
664
|
* import { HashSet, pipe } from "effect"
|
|
655
665
|
*
|
|
@@ -675,9 +685,10 @@ export const some: {
|
|
|
675
685
|
<A>(f: Predicate<A>): (self: HashSet<A>) => boolean
|
|
676
686
|
|
|
677
687
|
/**
|
|
678
|
-
* @example
|
|
688
|
+
* @example
|
|
679
689
|
*
|
|
680
690
|
* ```ts
|
|
691
|
+
* // `data-first` API
|
|
681
692
|
* import * as assert from "node:assert/strict"
|
|
682
693
|
* import { HashSet } from "effect"
|
|
683
694
|
*
|
|
@@ -706,9 +717,10 @@ export const some: {
|
|
|
706
717
|
* @memberof HashSet
|
|
707
718
|
* @since 2.0.0
|
|
708
719
|
* @category elements
|
|
709
|
-
* @example
|
|
720
|
+
* @example
|
|
710
721
|
*
|
|
711
722
|
* ```ts
|
|
723
|
+
* // Syntax with Refinement
|
|
712
724
|
* import { HashSet, pipe, Predicate } from "effect"
|
|
713
725
|
*
|
|
714
726
|
* const numberOrString = HashSet.make(1, "1", "one", "uno")
|
|
@@ -730,9 +742,10 @@ export const some: {
|
|
|
730
742
|
* ) // HashSet.HashSet<string>
|
|
731
743
|
* ```
|
|
732
744
|
*
|
|
733
|
-
* @example
|
|
745
|
+
* @example
|
|
734
746
|
*
|
|
735
747
|
* ```ts
|
|
748
|
+
* // Syntax with Predicate
|
|
736
749
|
* import { HashSet, pipe } from "effect"
|
|
737
750
|
*
|
|
738
751
|
* const set = HashSet.make(1, 2, 3)
|
|
@@ -752,7 +765,7 @@ export const some: {
|
|
|
752
765
|
*
|
|
753
766
|
* @returns A boolean once it has evaluated that whole collection fulfill the
|
|
754
767
|
* Predicate function
|
|
755
|
-
* @see Other `HashSet` elements are {@link has} {@link some} {@link isSubset}
|
|
768
|
+
* @see Other `HashSet` elements are {@link module:HashSet.has} {@link module:HashSet.some} {@link module:HashSet.isSubset}
|
|
756
769
|
*/
|
|
757
770
|
export const every: {
|
|
758
771
|
/**
|
|
@@ -859,9 +872,10 @@ export const every: {
|
|
|
859
872
|
* @memberof HashSet
|
|
860
873
|
* @since 2.0.0
|
|
861
874
|
* @category elements
|
|
862
|
-
* @example
|
|
875
|
+
* @example
|
|
863
876
|
*
|
|
864
877
|
* ```ts
|
|
878
|
+
* // Syntax
|
|
865
879
|
* import { HashSet, pipe } from "effect"
|
|
866
880
|
*
|
|
867
881
|
* const set1 = HashSet.make(0, 1)
|
|
@@ -881,7 +895,7 @@ export const every: {
|
|
|
881
895
|
* HashSet.isSubset(set1, set3) // true)
|
|
882
896
|
* ```
|
|
883
897
|
*
|
|
884
|
-
* @see Other `HashSet` elements are {@link has} {@link some} {@link every}
|
|
898
|
+
* @see Other `HashSet` elements are {@link module:HashSet.has} {@link module:HashSet.some} {@link module:HashSet.every}
|
|
885
899
|
*/
|
|
886
900
|
export const isSubset: {
|
|
887
901
|
/**
|
|
@@ -948,7 +962,7 @@ export const isSubset: {
|
|
|
948
962
|
* }
|
|
949
963
|
* ```
|
|
950
964
|
*
|
|
951
|
-
* @see Other `HashSet` getters are {@link toValues} {@link size}
|
|
965
|
+
* @see Other `HashSet` getters are {@link module:HashSet.toValues} {@link module:HashSet.size}
|
|
952
966
|
*/
|
|
953
967
|
export const values: <A>(self: HashSet<A>) => IterableIterator<A> = HS.values
|
|
954
968
|
|
|
@@ -975,7 +989,7 @@ export const values: <A>(self: HashSet<A>) => IterableIterator<A> = HS.values
|
|
|
975
989
|
* )
|
|
976
990
|
* ```
|
|
977
991
|
*
|
|
978
|
-
* @see Other `HashSet` getters are {@link values} {@link size}
|
|
992
|
+
* @see Other `HashSet` getters are {@link module:HashSet.values} {@link module:HashSet.size}
|
|
979
993
|
*/
|
|
980
994
|
export const toValues = <A>(self: HashSet<A>): Array<A> => Array.from(values(self))
|
|
981
995
|
|
|
@@ -1001,7 +1015,7 @@ export const toValues = <A>(self: HashSet<A>): Array<A> => Array.from(values(sel
|
|
|
1001
1015
|
* )
|
|
1002
1016
|
* ```
|
|
1003
1017
|
*
|
|
1004
|
-
* @see Other `HashSet` getters are {@link values} {@link toValues}
|
|
1018
|
+
* @see Other `HashSet` getters are {@link module:HashSet.values} {@link module:HashSet.toValues}
|
|
1005
1019
|
*/
|
|
1006
1020
|
export const size: <A>(self: HashSet<A>) => number = HS.size
|
|
1007
1021
|
|
|
@@ -1049,7 +1063,7 @@ export const size: <A>(self: HashSet<A>) => number = HS.size
|
|
|
1049
1063
|
* console.log(HashSet.toValues(mutableSet).sort((a, b) => a - b)) // [0, 1, 2, 3, ...rest]
|
|
1050
1064
|
* ```
|
|
1051
1065
|
*
|
|
1052
|
-
* @see Other `HashSet` mutations are {@link add} {@link remove} {@link toggle} {@link endMutation} {@link mutate}
|
|
1066
|
+
* @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}
|
|
1053
1067
|
*/
|
|
1054
1068
|
export const beginMutation: <A>(self: HashSet<A>) => HashSet<A> = HS.beginMutation
|
|
1055
1069
|
|
|
@@ -1097,7 +1111,7 @@ export const beginMutation: <A>(self: HashSet<A>) => HashSet<A> = HS.beginMutati
|
|
|
1097
1111
|
* assert.deepStrictEqual(HashSet.toValues(newSet).sort(), [1, 2, 3, 4])
|
|
1098
1112
|
* ```
|
|
1099
1113
|
*
|
|
1100
|
-
* @see Other `HashSet` mutations are {@
|
|
1114
|
+
* @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}
|
|
1101
1115
|
*/
|
|
1102
1116
|
export const endMutation: <A>(self: HashSet<A>) => HashSet<A> = HS.endMutation
|
|
1103
1117
|
|
|
@@ -1105,14 +1119,15 @@ export const endMutation: <A>(self: HashSet<A>) => HashSet<A> = HS.endMutation
|
|
|
1105
1119
|
* Mutates the `HashSet` within the context of the provided function.
|
|
1106
1120
|
*
|
|
1107
1121
|
* You can consider it a functional abstraction on top of the lower-level
|
|
1108
|
-
* mutation primitives of {@
|
|
1109
|
-
* context` `->` {@
|
|
1122
|
+
* mutation primitives of {@link module:HashSet.beginMutation} `->` `mutable
|
|
1123
|
+
* context` `->` {@link HashSet.endMutation}.
|
|
1110
1124
|
*
|
|
1111
1125
|
* @memberof HashSet
|
|
1112
1126
|
* @since 2.0.0
|
|
1113
|
-
* @example
|
|
1127
|
+
* @example
|
|
1114
1128
|
*
|
|
1115
1129
|
* ```ts
|
|
1130
|
+
* // Syntax
|
|
1116
1131
|
* import { HashSet, pipe } from "effect"
|
|
1117
1132
|
*
|
|
1118
1133
|
* // with data-last, a.k.a. pipeable API
|
|
@@ -1139,13 +1154,14 @@ export const endMutation: <A>(self: HashSet<A>) => HashSet<A> = HS.endMutation
|
|
|
1139
1154
|
* })
|
|
1140
1155
|
* ```
|
|
1141
1156
|
*
|
|
1142
|
-
* @see Other `HashSet` mutations are {@
|
|
1157
|
+
* @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}
|
|
1143
1158
|
*/
|
|
1144
1159
|
export const mutate: {
|
|
1145
1160
|
/**
|
|
1146
|
-
* @example
|
|
1161
|
+
* @example
|
|
1147
1162
|
*
|
|
1148
1163
|
* ```ts
|
|
1164
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1149
1165
|
* import { HashSet, pipe } from "effect"
|
|
1150
1166
|
* import assert from "node:assert/strict"
|
|
1151
1167
|
*
|
|
@@ -1179,9 +1195,10 @@ export const mutate: {
|
|
|
1179
1195
|
<A>(f: (set: HashSet<A>) => void): (self: HashSet<A>) => HashSet<A>
|
|
1180
1196
|
|
|
1181
1197
|
/**
|
|
1182
|
-
* @example
|
|
1198
|
+
* @example
|
|
1183
1199
|
*
|
|
1184
1200
|
* ```ts
|
|
1201
|
+
* // `data-first` API
|
|
1185
1202
|
* import { HashSet } from "effect"
|
|
1186
1203
|
* import assert from "node:assert/strict"
|
|
1187
1204
|
*
|
|
@@ -1223,9 +1240,10 @@ export const mutate: {
|
|
|
1223
1240
|
* with the added value.
|
|
1224
1241
|
* @memberof HashSet
|
|
1225
1242
|
* @since 2.0.0
|
|
1226
|
-
* @example
|
|
1243
|
+
* @example
|
|
1227
1244
|
*
|
|
1228
1245
|
* ```ts
|
|
1246
|
+
* // Syntax
|
|
1229
1247
|
* import { HashSet, pipe } from "effect"
|
|
1230
1248
|
*
|
|
1231
1249
|
* // with data-last, a.k.a. pipeable API
|
|
@@ -1238,13 +1256,14 @@ export const mutate: {
|
|
|
1238
1256
|
* HashSet.add(HashSet.empty(), 0)
|
|
1239
1257
|
* ```
|
|
1240
1258
|
*
|
|
1241
|
-
* @see Other `HashSet` mutations are {@link remove} {@link toggle} {@link beginMutation} {@link endMutation} {@link mutate}
|
|
1259
|
+
* @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}
|
|
1242
1260
|
*/
|
|
1243
1261
|
export const add: {
|
|
1244
1262
|
/**
|
|
1245
|
-
* @example
|
|
1263
|
+
* @example
|
|
1246
1264
|
*
|
|
1247
1265
|
* ```ts
|
|
1266
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1248
1267
|
* import { HashSet, pipe } from "effect"
|
|
1249
1268
|
* import assert from "node:assert/strict"
|
|
1250
1269
|
*
|
|
@@ -1264,9 +1283,10 @@ export const add: {
|
|
|
1264
1283
|
<A>(value: A): (self: HashSet<A>) => HashSet<A>
|
|
1265
1284
|
|
|
1266
1285
|
/**
|
|
1267
|
-
* @example
|
|
1286
|
+
* @example
|
|
1268
1287
|
*
|
|
1269
1288
|
* ```ts
|
|
1289
|
+
* // `data-first` API
|
|
1270
1290
|
* import { HashSet, pipe } from "effect"
|
|
1271
1291
|
* import assert from "node:assert/strict"
|
|
1272
1292
|
*
|
|
@@ -1289,9 +1309,10 @@ export const add: {
|
|
|
1289
1309
|
*
|
|
1290
1310
|
* @memberof HashSet
|
|
1291
1311
|
* @since 2.0.0
|
|
1292
|
-
* @example
|
|
1312
|
+
* @example
|
|
1293
1313
|
*
|
|
1294
1314
|
* ```ts
|
|
1315
|
+
* // Syntax
|
|
1295
1316
|
* import { HashSet, pipe } from "effect"
|
|
1296
1317
|
*
|
|
1297
1318
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -1304,13 +1325,14 @@ export const add: {
|
|
|
1304
1325
|
* HashSet.remove(HashSet.make(0, 1, 2), 0)
|
|
1305
1326
|
* ```
|
|
1306
1327
|
*
|
|
1307
|
-
* @see Other `HashSet` mutations are {@link add} {@link toggle} {@link beginMutation} {@link endMutation} {@link mutate}
|
|
1328
|
+
* @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}
|
|
1308
1329
|
*/
|
|
1309
1330
|
export const remove: {
|
|
1310
1331
|
/**
|
|
1311
|
-
* @example
|
|
1332
|
+
* @example
|
|
1312
1333
|
*
|
|
1313
1334
|
* ```ts
|
|
1335
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1314
1336
|
* import { HashSet, pipe } from "effect"
|
|
1315
1337
|
* import * as assert from "node:assert/strict"
|
|
1316
1338
|
*
|
|
@@ -1326,9 +1348,10 @@ export const remove: {
|
|
|
1326
1348
|
<A>(value: A): (self: HashSet<A>) => HashSet<A>
|
|
1327
1349
|
|
|
1328
1350
|
/**
|
|
1329
|
-
* @example
|
|
1351
|
+
* @example
|
|
1330
1352
|
*
|
|
1331
1353
|
* ```ts
|
|
1354
|
+
* // `data-first` API
|
|
1332
1355
|
* import { HashSet, pipe } from "effect"
|
|
1333
1356
|
* import * as assert from "node:assert/strict"
|
|
1334
1357
|
*
|
|
@@ -1357,9 +1380,10 @@ export const remove: {
|
|
|
1357
1380
|
*
|
|
1358
1381
|
* @memberof HashSet
|
|
1359
1382
|
* @since 2.0.0
|
|
1360
|
-
* @example
|
|
1383
|
+
* @example
|
|
1361
1384
|
*
|
|
1362
1385
|
* ```ts
|
|
1386
|
+
* // Syntax
|
|
1363
1387
|
* import { HashSet, pipe } from "effect"
|
|
1364
1388
|
*
|
|
1365
1389
|
* // with data-last, a.k.a. pipeable API
|
|
@@ -1372,13 +1396,14 @@ export const remove: {
|
|
|
1372
1396
|
* HashSet.difference(HashSet.make(1, 2, 3), HashSet.make(3, 4, 5))
|
|
1373
1397
|
* ```
|
|
1374
1398
|
*
|
|
1375
|
-
* @see Other `HashSet` operations are {@link intersection} {@link union}
|
|
1399
|
+
* @see Other `HashSet` operations are {@link module:HashSet.intersection} {@link module:HashSet.union}
|
|
1376
1400
|
*/
|
|
1377
1401
|
export const difference: {
|
|
1378
1402
|
/**
|
|
1379
|
-
* @example
|
|
1403
|
+
* @example
|
|
1380
1404
|
*
|
|
1381
1405
|
* ```ts
|
|
1406
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1382
1407
|
* import { HashSet, pipe } from "effect"
|
|
1383
1408
|
* import * as assert from "node:assert/strict"
|
|
1384
1409
|
*
|
|
@@ -1407,9 +1432,10 @@ export const difference: {
|
|
|
1407
1432
|
<A>(that: Iterable<A>): (self: HashSet<A>) => HashSet<A>
|
|
1408
1433
|
|
|
1409
1434
|
/**
|
|
1410
|
-
* @example
|
|
1435
|
+
* @example
|
|
1411
1436
|
*
|
|
1412
1437
|
* ```ts
|
|
1438
|
+
* // `data-first` API
|
|
1413
1439
|
* import { HashSet } from "effect"
|
|
1414
1440
|
* import * as assert from "node:assert/strict"
|
|
1415
1441
|
*
|
|
@@ -1450,9 +1476,10 @@ export const difference: {
|
|
|
1450
1476
|
*
|
|
1451
1477
|
* @memberof HashSet
|
|
1452
1478
|
* @since 2.0.0
|
|
1453
|
-
* @example
|
|
1479
|
+
* @example
|
|
1454
1480
|
*
|
|
1455
1481
|
* ```ts
|
|
1482
|
+
* // Syntax
|
|
1456
1483
|
* import { HashSet, pipe } from "effect"
|
|
1457
1484
|
*
|
|
1458
1485
|
* // with data-last, a.k.a. pipeable API
|
|
@@ -1465,13 +1492,14 @@ export const difference: {
|
|
|
1465
1492
|
* HashSet.intersection(HashSet.make(1, 2, 3), HashSet.make(2, 3, 4))
|
|
1466
1493
|
* ```
|
|
1467
1494
|
*
|
|
1468
|
-
* @see Other `HashSet` operations are {@link difference} {@link union}
|
|
1495
|
+
* @see Other `HashSet` operations are {@link module:HashSet.difference} {@link module:HashSet.union}
|
|
1469
1496
|
*/
|
|
1470
1497
|
export const intersection: {
|
|
1471
1498
|
/**
|
|
1472
|
-
* @example
|
|
1499
|
+
* @example
|
|
1473
1500
|
*
|
|
1474
1501
|
* ```ts
|
|
1502
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1475
1503
|
* import { HashSet, pipe } from "effect"
|
|
1476
1504
|
* import * as assert from "node:assert/strict"
|
|
1477
1505
|
*
|
|
@@ -1500,9 +1528,10 @@ export const intersection: {
|
|
|
1500
1528
|
<A>(that: Iterable<A>): (self: HashSet<A>) => HashSet<A>
|
|
1501
1529
|
|
|
1502
1530
|
/**
|
|
1503
|
-
* @example
|
|
1531
|
+
* @example
|
|
1504
1532
|
*
|
|
1505
1533
|
* ```ts
|
|
1534
|
+
* // `data-first` API
|
|
1506
1535
|
* import { HashSet } from "effect"
|
|
1507
1536
|
* import * as assert from "node:assert/strict"
|
|
1508
1537
|
*
|
|
@@ -1542,9 +1571,10 @@ export const intersection: {
|
|
|
1542
1571
|
*
|
|
1543
1572
|
* @memberof HashSet
|
|
1544
1573
|
* @since 2.0.0
|
|
1545
|
-
* @example
|
|
1574
|
+
* @example
|
|
1546
1575
|
*
|
|
1547
1576
|
* ```ts
|
|
1577
|
+
* // Syntax
|
|
1548
1578
|
* import { HashSet, pipe } from "effect"
|
|
1549
1579
|
*
|
|
1550
1580
|
* // with data-last, a.k.a. pipeable API
|
|
@@ -1557,13 +1587,14 @@ export const intersection: {
|
|
|
1557
1587
|
* HashSet.union(HashSet.make(1, 2, 3), HashSet.make(3, 4, 5))
|
|
1558
1588
|
* ```
|
|
1559
1589
|
*
|
|
1560
|
-
* @see Other `HashSet` operations are {@link difference} {@link intersection}
|
|
1590
|
+
* @see Other `HashSet` operations are {@link module:HashSet.difference} {@link module:HashSet.intersection}
|
|
1561
1591
|
*/
|
|
1562
1592
|
export const union: {
|
|
1563
1593
|
/**
|
|
1564
|
-
* @example
|
|
1594
|
+
* @example
|
|
1565
1595
|
*
|
|
1566
1596
|
* ```ts
|
|
1597
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1567
1598
|
* import { HashSet, pipe } from "effect"
|
|
1568
1599
|
* import * as assert from "node:assert/strict"
|
|
1569
1600
|
*
|
|
@@ -1598,9 +1629,10 @@ export const union: {
|
|
|
1598
1629
|
<A>(that: Iterable<A>): (self: HashSet<A>) => HashSet<A>
|
|
1599
1630
|
|
|
1600
1631
|
/**
|
|
1601
|
-
* @example
|
|
1632
|
+
* @example
|
|
1602
1633
|
*
|
|
1603
1634
|
* ```ts
|
|
1635
|
+
* // `data-first` API
|
|
1604
1636
|
* import { HashSet } from "effect"
|
|
1605
1637
|
* import * as assert from "node:assert/strict"
|
|
1606
1638
|
*
|
|
@@ -1644,9 +1676,10 @@ export const union: {
|
|
|
1644
1676
|
*
|
|
1645
1677
|
* @memberof HashSet
|
|
1646
1678
|
* @since 2.0.0
|
|
1647
|
-
* @example
|
|
1679
|
+
* @example
|
|
1648
1680
|
*
|
|
1649
1681
|
* ```ts
|
|
1682
|
+
* // Syntax
|
|
1650
1683
|
* import { HashSet, pipe } from "effect"
|
|
1651
1684
|
*
|
|
1652
1685
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -1661,13 +1694,14 @@ export const union: {
|
|
|
1661
1694
|
*
|
|
1662
1695
|
* @returns A new `HashSet` where the toggled value is being either added or
|
|
1663
1696
|
* removed based on the initial `HashSet` state.
|
|
1664
|
-
* @see Other `HashSet` mutations are {@link add} {@link remove} {@link beginMutation} {@link endMutation} {@link mutate}
|
|
1697
|
+
* @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}
|
|
1665
1698
|
*/
|
|
1666
1699
|
export const toggle: {
|
|
1667
1700
|
/**
|
|
1668
|
-
* @example
|
|
1701
|
+
* @example
|
|
1669
1702
|
*
|
|
1670
1703
|
* ```ts
|
|
1704
|
+
* // `data-last` a.k.a. `pipeable` API
|
|
1671
1705
|
* import { HashSet, pipe } from "effect"
|
|
1672
1706
|
* import assert from "node:assert/strict"
|
|
1673
1707
|
*
|
|
@@ -1693,9 +1727,10 @@ export const toggle: {
|
|
|
1693
1727
|
<A>(value: A): (self: HashSet<A>) => HashSet<A>
|
|
1694
1728
|
|
|
1695
1729
|
/**
|
|
1696
|
-
* @example
|
|
1730
|
+
* @example
|
|
1697
1731
|
*
|
|
1698
1732
|
* ```ts
|
|
1733
|
+
* // `data-first` API
|
|
1699
1734
|
* import { HashSet, pipe } from "effect"
|
|
1700
1735
|
* import assert from "node:assert/strict"
|
|
1701
1736
|
*
|
|
@@ -1729,9 +1764,10 @@ export const toggle: {
|
|
|
1729
1764
|
* @memberof HashSet
|
|
1730
1765
|
* @since 2.0.0
|
|
1731
1766
|
* @category mapping
|
|
1732
|
-
* @example
|
|
1767
|
+
* @example
|
|
1733
1768
|
*
|
|
1734
1769
|
* ```ts
|
|
1770
|
+
* // Syntax
|
|
1735
1771
|
* import { HashSet, pipe } from "effect"
|
|
1736
1772
|
*
|
|
1737
1773
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -1793,9 +1829,10 @@ export const map: {
|
|
|
1793
1829
|
* @memberof HashSet
|
|
1794
1830
|
* @since 2.0.0
|
|
1795
1831
|
* @category sequencing
|
|
1796
|
-
* @example
|
|
1832
|
+
* @example
|
|
1797
1833
|
*
|
|
1798
1834
|
* ```ts
|
|
1835
|
+
* // Syntax
|
|
1799
1836
|
* import { HashSet, pipe } from "effect"
|
|
1800
1837
|
*
|
|
1801
1838
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -1859,9 +1896,10 @@ export const flatMap: {
|
|
|
1859
1896
|
* @memberof HashSet
|
|
1860
1897
|
* @since 2.0.0
|
|
1861
1898
|
* @category traversing
|
|
1862
|
-
* @example
|
|
1899
|
+
* @example
|
|
1863
1900
|
*
|
|
1864
1901
|
* ```ts
|
|
1902
|
+
* // Syntax
|
|
1865
1903
|
* import { HashSet, pipe } from "effect"
|
|
1866
1904
|
*
|
|
1867
1905
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -1923,9 +1961,10 @@ export const forEach: {
|
|
|
1923
1961
|
* @memberof HashSet
|
|
1924
1962
|
* @since 2.0.0
|
|
1925
1963
|
* @category folding
|
|
1926
|
-
* @example
|
|
1964
|
+
* @example
|
|
1927
1965
|
*
|
|
1928
1966
|
* ```ts
|
|
1967
|
+
* // Syntax
|
|
1929
1968
|
* import { HashSet, pipe } from "effect"
|
|
1930
1969
|
*
|
|
1931
1970
|
* const sum = (a: number, b: number): number => a + b
|
|
@@ -1987,9 +2026,10 @@ export const reduce: {
|
|
|
1987
2026
|
* @memberof HashSet
|
|
1988
2027
|
* @since 2.0.0
|
|
1989
2028
|
* @category filtering
|
|
1990
|
-
* @example
|
|
2029
|
+
* @example
|
|
1991
2030
|
*
|
|
1992
2031
|
* ```ts
|
|
2032
|
+
* // Syntax with Predicate
|
|
1993
2033
|
* import { HashSet, type Predicate, pipe } from "effect"
|
|
1994
2034
|
*
|
|
1995
2035
|
* const filterPositiveNumbers: Predicate.Predicate<number> = (n) => n > 0
|
|
@@ -2007,9 +2047,10 @@ export const reduce: {
|
|
|
2007
2047
|
* HashSet.filter(HashSet.make(-2, -1, 0, 1, 2), filterPositiveNumbers)
|
|
2008
2048
|
* ```
|
|
2009
2049
|
*
|
|
2010
|
-
* @example
|
|
2050
|
+
* @example
|
|
2011
2051
|
*
|
|
2012
2052
|
* ```ts
|
|
2053
|
+
* /// Syntax with Refinement
|
|
2013
2054
|
* import { HashSet, pipe } from "effect"
|
|
2014
2055
|
*
|
|
2015
2056
|
* const stringRefinement = (value: unknown): value is string =>
|
|
@@ -2141,9 +2182,10 @@ export const filter: {
|
|
|
2141
2182
|
* @memberof HashSet
|
|
2142
2183
|
* @since 2.0.0
|
|
2143
2184
|
* @category partitioning
|
|
2144
|
-
* @example
|
|
2185
|
+
* @example
|
|
2145
2186
|
*
|
|
2146
2187
|
* ```ts
|
|
2188
|
+
* // Syntax with Predicate
|
|
2147
2189
|
* import { HashSet, pipe, Predicate } from "effect"
|
|
2148
2190
|
*
|
|
2149
2191
|
* // with `data-last`, a.k.a. `pipeable` API
|
|
@@ -2161,9 +2203,10 @@ export const filter: {
|
|
|
2161
2203
|
* HashSet.partition(HashSet.make(0, 1, 2, 3, 4, 5), (n) => n % 2 === 0)
|
|
2162
2204
|
* ```
|
|
2163
2205
|
*
|
|
2164
|
-
* @example
|
|
2206
|
+
* @example
|
|
2165
2207
|
*
|
|
2166
2208
|
* ```ts
|
|
2209
|
+
* // Syntax with Refinement
|
|
2167
2210
|
* import { HashSet, pipe, Predicate } from "effect"
|
|
2168
2211
|
*
|
|
2169
2212
|
* const stringRefinement: Predicate.Refinement<string | number, string> = (
|