effect 4.0.0-beta.18 → 4.0.0-beta.19

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.
Files changed (103) hide show
  1. package/dist/Array.d.ts +127 -299
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +102 -62
  4. package/dist/Array.js.map +1 -1
  5. package/dist/Cache.d.ts.map +1 -1
  6. package/dist/Cache.js +5 -4
  7. package/dist/Cache.js.map +1 -1
  8. package/dist/Channel.d.ts +97 -11
  9. package/dist/Channel.d.ts.map +1 -1
  10. package/dist/Channel.js +72 -29
  11. package/dist/Channel.js.map +1 -1
  12. package/dist/Chunk.d.ts +54 -247
  13. package/dist/Chunk.d.ts.map +1 -1
  14. package/dist/Chunk.js +36 -67
  15. package/dist/Chunk.js.map +1 -1
  16. package/dist/Effect.d.ts +304 -336
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +85 -26
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/Filter.d.ts +0 -33
  21. package/dist/Filter.d.ts.map +1 -1
  22. package/dist/Filter.js +0 -13
  23. package/dist/Filter.js.map +1 -1
  24. package/dist/HashMap.d.ts +15 -14
  25. package/dist/HashMap.d.ts.map +1 -1
  26. package/dist/HashMap.js +4 -4
  27. package/dist/HashMap.js.map +1 -1
  28. package/dist/Iterable.d.ts +40 -39
  29. package/dist/Iterable.d.ts.map +1 -1
  30. package/dist/Iterable.js +94 -22
  31. package/dist/Iterable.js.map +1 -1
  32. package/dist/Option.d.ts +22 -15
  33. package/dist/Option.d.ts.map +1 -1
  34. package/dist/Option.js +14 -7
  35. package/dist/Option.js.map +1 -1
  36. package/dist/Pull.d.ts.map +1 -1
  37. package/dist/Pull.js +1 -1
  38. package/dist/Pull.js.map +1 -1
  39. package/dist/Record.d.ts +24 -120
  40. package/dist/Record.d.ts.map +1 -1
  41. package/dist/Record.js +21 -41
  42. package/dist/Record.js.map +1 -1
  43. package/dist/Sink.d.ts +11 -11
  44. package/dist/Sink.d.ts.map +1 -1
  45. package/dist/Sink.js +53 -6
  46. package/dist/Sink.js.map +1 -1
  47. package/dist/Stream.d.ts +198 -386
  48. package/dist/Stream.d.ts.map +1 -1
  49. package/dist/Stream.js +103 -59
  50. package/dist/Stream.js.map +1 -1
  51. package/dist/Trie.d.ts +18 -17
  52. package/dist/Trie.d.ts.map +1 -1
  53. package/dist/Trie.js +5 -5
  54. package/dist/Trie.js.map +1 -1
  55. package/dist/TxHashMap.d.ts +27 -26
  56. package/dist/TxHashMap.d.ts.map +1 -1
  57. package/dist/TxHashMap.js +8 -8
  58. package/dist/TxHashMap.js.map +1 -1
  59. package/dist/internal/effect.js +99 -42
  60. package/dist/internal/effect.js.map +1 -1
  61. package/dist/internal/hashMap.js +3 -2
  62. package/dist/internal/hashMap.js.map +1 -1
  63. package/dist/internal/trie.js +5 -4
  64. package/dist/internal/trie.js.map +1 -1
  65. package/dist/unstable/cli/Command.js +1 -1
  66. package/dist/unstable/cli/Command.js.map +1 -1
  67. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  68. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  69. package/dist/unstable/cluster/Sharding.js +1 -1
  70. package/dist/unstable/cluster/Sharding.js.map +1 -1
  71. package/dist/unstable/encoding/Sse.js +1 -1
  72. package/dist/unstable/encoding/Sse.js.map +1 -1
  73. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  74. package/dist/unstable/rpc/RpcServer.js +1 -2
  75. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  76. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  77. package/dist/unstable/socket/Socket.js +3 -3
  78. package/dist/unstable/socket/Socket.js.map +1 -1
  79. package/package.json +1 -1
  80. package/src/Array.ts +190 -342
  81. package/src/Cache.ts +6 -5
  82. package/src/Channel.ts +506 -102
  83. package/src/Chunk.ts +81 -268
  84. package/src/Effect.ts +399 -401
  85. package/src/Filter.ts +0 -57
  86. package/src/HashMap.ts +15 -14
  87. package/src/Iterable.ts +105 -50
  88. package/src/Option.ts +30 -20
  89. package/src/Pull.ts +1 -1
  90. package/src/Record.ts +43 -152
  91. package/src/Sink.ts +75 -23
  92. package/src/Stream.ts +442 -502
  93. package/src/Trie.ts +18 -17
  94. package/src/TxHashMap.ts +29 -28
  95. package/src/internal/effect.ts +368 -163
  96. package/src/internal/hashMap.ts +7 -5
  97. package/src/internal/trie.ts +16 -9
  98. package/src/unstable/cli/Command.ts +2 -2
  99. package/src/unstable/cluster/K8sHttpClient.ts +4 -4
  100. package/src/unstable/cluster/Sharding.ts +1 -1
  101. package/src/unstable/encoding/Sse.ts +1 -1
  102. package/src/unstable/rpc/RpcServer.ts +1 -7
  103. package/src/unstable/socket/Socket.ts +9 -11
package/src/Trie.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  * @since 2.0.0
17
17
  */
18
18
  import type { Equal } from "./Equal.ts"
19
+ import type * as Filter from "./Filter.ts"
19
20
  import type { Inspectable } from "./Inspectable.ts"
20
21
  import * as TR from "./internal/trie.ts"
21
22
  import type { Option } from "./Option.ts"
@@ -1488,13 +1489,13 @@ export const filter: {
1488
1489
  } = TR.filter
1489
1490
 
1490
1491
  /**
1491
- * Maps over the entries of the `Trie` using the specified partial function
1492
- * and filters out `None` values.
1492
+ * Maps over the entries of the `Trie` using the specified filter and keeps
1493
+ * only successful results.
1493
1494
  *
1494
1495
  * @example
1495
1496
  * ```ts
1496
1497
  * import * as Equal from "effect/Equal"
1497
- * import * as Option from "effect/Option"
1498
+ * import * as Result from "effect/Result"
1498
1499
  * import * as Trie from "effect/Trie"
1499
1500
  * import * as assert from "node:assert"
1500
1501
  *
@@ -1515,7 +1516,7 @@ export const filter: {
1515
1516
  *
1516
1517
  * assert.equal(
1517
1518
  * Equal.equals(
1518
- * Trie.filterMap(trie, (v) => v > 1 ? Option.some(v) : Option.none()),
1519
+ * Trie.filterMap(trie, (v) => v > 1 ? Result.succeed(v) : Result.failVoid),
1519
1520
  * trieMapV
1520
1521
  * ),
1521
1522
  * true
@@ -1524,7 +1525,7 @@ export const filter: {
1524
1525
  * Equal.equals(
1525
1526
  * Trie.filterMap(
1526
1527
  * trie,
1527
- * (v, k) => k.length > 3 ? Option.some(v) : Option.none()
1528
+ * (v, k) => k.length > 3 ? Result.succeed(v) : Result.failVoid
1528
1529
  * ),
1529
1530
  * trieMapK
1530
1531
  * ),
@@ -1537,13 +1538,13 @@ export const filter: {
1537
1538
  */
1538
1539
  export const filterMap: {
1539
1540
  /**
1540
- * Maps over the entries of the `Trie` using the specified partial function
1541
- * and filters out `None` values.
1541
+ * Maps over the entries of the `Trie` using the specified filter and keeps
1542
+ * only successful results.
1542
1543
  *
1543
1544
  * @example
1544
1545
  * ```ts
1545
1546
  * import * as Equal from "effect/Equal"
1546
- * import * as Option from "effect/Option"
1547
+ * import * as Result from "effect/Result"
1547
1548
  * import * as Trie from "effect/Trie"
1548
1549
  * import * as assert from "node:assert"
1549
1550
  *
@@ -1564,7 +1565,7 @@ export const filterMap: {
1564
1565
  *
1565
1566
  * assert.equal(
1566
1567
  * Equal.equals(
1567
- * Trie.filterMap(trie, (v) => v > 1 ? Option.some(v) : Option.none()),
1568
+ * Trie.filterMap(trie, (v) => v > 1 ? Result.succeed(v) : Result.failVoid),
1568
1569
  * trieMapV
1569
1570
  * ),
1570
1571
  * true
@@ -1573,7 +1574,7 @@ export const filterMap: {
1573
1574
  * Equal.equals(
1574
1575
  * Trie.filterMap(
1575
1576
  * trie,
1576
- * (v, k) => k.length > 3 ? Option.some(v) : Option.none()
1577
+ * (v, k) => k.length > 3 ? Result.succeed(v) : Result.failVoid
1577
1578
  * ),
1578
1579
  * trieMapK
1579
1580
  * ),
@@ -1584,15 +1585,15 @@ export const filterMap: {
1584
1585
  * @since 2.0.0
1585
1586
  * @category filtering
1586
1587
  */
1587
- <A, B>(f: (value: A, key: string) => Option<B>): (self: Trie<A>) => Trie<B>
1588
+ <A, B, X>(f: Filter.Filter<A, B, X, [key: string]>): (self: Trie<A>) => Trie<B>
1588
1589
  /**
1589
- * Maps over the entries of the `Trie` using the specified partial function
1590
- * and filters out `None` values.
1590
+ * Maps over the entries of the `Trie` using the specified filter and keeps
1591
+ * only successful results.
1591
1592
  *
1592
1593
  * @example
1593
1594
  * ```ts
1594
1595
  * import * as Equal from "effect/Equal"
1595
- * import * as Option from "effect/Option"
1596
+ * import * as Result from "effect/Result"
1596
1597
  * import * as Trie from "effect/Trie"
1597
1598
  * import * as assert from "node:assert"
1598
1599
  *
@@ -1613,7 +1614,7 @@ export const filterMap: {
1613
1614
  *
1614
1615
  * assert.equal(
1615
1616
  * Equal.equals(
1616
- * Trie.filterMap(trie, (v) => v > 1 ? Option.some(v) : Option.none()),
1617
+ * Trie.filterMap(trie, (v) => v > 1 ? Result.succeed(v) : Result.failVoid),
1617
1618
  * trieMapV
1618
1619
  * ),
1619
1620
  * true
@@ -1622,7 +1623,7 @@ export const filterMap: {
1622
1623
  * Equal.equals(
1623
1624
  * Trie.filterMap(
1624
1625
  * trie,
1625
- * (v, k) => k.length > 3 ? Option.some(v) : Option.none()
1626
+ * (v, k) => k.length > 3 ? Result.succeed(v) : Result.failVoid
1626
1627
  * ),
1627
1628
  * trieMapK
1628
1629
  * ),
@@ -1633,7 +1634,7 @@ export const filterMap: {
1633
1634
  * @since 2.0.0
1634
1635
  * @category filtering
1635
1636
  */
1636
- <A, B>(self: Trie<A>, f: (value: A, key: string) => Option<B>): Trie<B>
1637
+ <A, B, X>(self: Trie<A>, f: Filter.Filter<A, B, X, [key: string]>): Trie<B>
1637
1638
  } = TR.filterMap
1638
1639
 
1639
1640
  /**
package/src/TxHashMap.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import * as Effect from "./Effect.ts"
6
+ import type * as Filter from "./Filter.ts"
6
7
  import { format } from "./Formatter.ts"
7
8
  import { dual } from "./Function.ts"
8
9
  import * as HashMap from "./HashMap.ts"
@@ -2720,15 +2721,15 @@ export const reduce: {
2720
2721
  )
2721
2722
 
2722
2723
  /**
2723
- * Combines filtering and mapping in a single operation. Applies a function that returns
2724
- * an Option to each entry, keeping only the Some values and transforming them.
2724
+ * Combines filtering and mapping in a single operation. Applies a filter to each
2725
+ * entry, keeping only successful results and transforming them.
2725
2726
  *
2726
2727
  * **Return behavior**: This function returns a new TxHashMap reference containing
2727
- * only the transformed entries that returned Some values. The original TxHashMap is not modified.
2728
+ * only the transformed entries that succeeded. The original TxHashMap is not modified.
2728
2729
  *
2729
2730
  * @example
2730
2731
  * ```ts
2731
- * import { Effect, Option, TxHashMap } from "effect"
2732
+ * import { Effect, Option, Result, TxHashMap } from "effect"
2732
2733
  *
2733
2734
  * const program = Effect.gen(function*() {
2734
2735
  * // Create a mixed data map
@@ -2743,10 +2744,10 @@ export const reduce: {
2743
2744
  * const activeAdminAges = yield* TxHashMap.filterMap(
2744
2745
  * userData,
2745
2746
  * (user, username) => {
2746
- * if (!user.active || user.role !== "admin") return Option.none()
2747
+ * if (!user.active || user.role !== "admin") return Result.failVoid
2747
2748
  * const age = parseInt(user.age)
2748
- * if (isNaN(age)) return Option.none()
2749
- * return Option.some({
2749
+ * if (isNaN(age)) return Result.failVoid
2750
+ * return Result.succeed({
2750
2751
  * username,
2751
2752
  * age,
2752
2753
  * seniority: age > 27 ? "senior" : "junior"
@@ -2764,7 +2765,7 @@ export const reduce: {
2764
2765
  * const validAges = yield* userData.pipe(
2765
2766
  * TxHashMap.filterMap((user) => {
2766
2767
  * const age = parseInt(user.age)
2767
- * return isNaN(age) ? Option.none() : Option.some(age)
2768
+ * return isNaN(age) ? Result.failVoid : Result.succeed(age)
2768
2769
  * })
2769
2770
  * )
2770
2771
  *
@@ -2778,15 +2779,15 @@ export const reduce: {
2778
2779
  */
2779
2780
  export const filterMap: {
2780
2781
  /**
2781
- * Combines filtering and mapping in a single operation. Applies a function that returns
2782
- * an Option to each entry, keeping only the Some values and transforming them.
2782
+ * Combines filtering and mapping in a single operation. Applies a filter to each
2783
+ * entry, keeping only successful results and transforming them.
2783
2784
  *
2784
2785
  * **Return behavior**: This function returns a new TxHashMap reference containing
2785
- * only the transformed entries that returned Some values. The original TxHashMap is not modified.
2786
+ * only the transformed entries that succeeded. The original TxHashMap is not modified.
2786
2787
  *
2787
2788
  * @example
2788
2789
  * ```ts
2789
- * import { Effect, Option, TxHashMap } from "effect"
2790
+ * import { Effect, Option, Result, TxHashMap } from "effect"
2790
2791
  *
2791
2792
  * const program = Effect.gen(function*() {
2792
2793
  * // Create a mixed data map
@@ -2801,10 +2802,10 @@ export const filterMap: {
2801
2802
  * const activeAdminAges = yield* TxHashMap.filterMap(
2802
2803
  * userData,
2803
2804
  * (user, username) => {
2804
- * if (!user.active || user.role !== "admin") return Option.none()
2805
+ * if (!user.active || user.role !== "admin") return Result.failVoid
2805
2806
  * const age = parseInt(user.age)
2806
- * if (isNaN(age)) return Option.none()
2807
- * return Option.some({
2807
+ * if (isNaN(age)) return Result.failVoid
2808
+ * return Result.succeed({
2808
2809
  * username,
2809
2810
  * age,
2810
2811
  * seniority: age > 27 ? "senior" : "junior"
@@ -2822,7 +2823,7 @@ export const filterMap: {
2822
2823
  * const validAges = yield* userData.pipe(
2823
2824
  * TxHashMap.filterMap((user) => {
2824
2825
  * const age = parseInt(user.age)
2825
- * return isNaN(age) ? Option.none() : Option.some(age)
2826
+ * return isNaN(age) ? Result.failVoid : Result.succeed(age)
2826
2827
  * })
2827
2828
  * )
2828
2829
  *
@@ -2834,17 +2835,17 @@ export const filterMap: {
2834
2835
  * @since 2.0.0
2835
2836
  * @category combinators
2836
2837
  */
2837
- <A, V, K>(f: (value: V, key: K) => Option.Option<A>): (self: TxHashMap<K, V>) => Effect.Effect<TxHashMap<K, A>, never, Effect.Transaction>
2838
+ <V, K, A, X>(f: Filter.Filter<V, A, X, [key: K]>): (self: TxHashMap<K, V>) => Effect.Effect<TxHashMap<K, A>, never, Effect.Transaction>
2838
2839
  /**
2839
- * Combines filtering and mapping in a single operation. Applies a function that returns
2840
- * an Option to each entry, keeping only the Some values and transforming them.
2840
+ * Combines filtering and mapping in a single operation. Applies a filter to each
2841
+ * entry, keeping only successful results and transforming them.
2841
2842
  *
2842
2843
  * **Return behavior**: This function returns a new TxHashMap reference containing
2843
- * only the transformed entries that returned Some values. The original TxHashMap is not modified.
2844
+ * only the transformed entries that succeeded. The original TxHashMap is not modified.
2844
2845
  *
2845
2846
  * @example
2846
2847
  * ```ts
2847
- * import { Effect, Option, TxHashMap } from "effect"
2848
+ * import { Effect, Option, Result, TxHashMap } from "effect"
2848
2849
  *
2849
2850
  * const program = Effect.gen(function*() {
2850
2851
  * // Create a mixed data map
@@ -2859,10 +2860,10 @@ export const filterMap: {
2859
2860
  * const activeAdminAges = yield* TxHashMap.filterMap(
2860
2861
  * userData,
2861
2862
  * (user, username) => {
2862
- * if (!user.active || user.role !== "admin") return Option.none()
2863
+ * if (!user.active || user.role !== "admin") return Result.failVoid
2863
2864
  * const age = parseInt(user.age)
2864
- * if (isNaN(age)) return Option.none()
2865
- * return Option.some({
2865
+ * if (isNaN(age)) return Result.failVoid
2866
+ * return Result.succeed({
2866
2867
  * username,
2867
2868
  * age,
2868
2869
  * seniority: age > 27 ? "senior" : "junior"
@@ -2880,7 +2881,7 @@ export const filterMap: {
2880
2881
  * const validAges = yield* userData.pipe(
2881
2882
  * TxHashMap.filterMap((user) => {
2882
2883
  * const age = parseInt(user.age)
2883
- * return isNaN(age) ? Option.none() : Option.some(age)
2884
+ * return isNaN(age) ? Result.failVoid : Result.succeed(age)
2884
2885
  * })
2885
2886
  * )
2886
2887
  *
@@ -2892,12 +2893,12 @@ export const filterMap: {
2892
2893
  * @since 2.0.0
2893
2894
  * @category combinators
2894
2895
  */
2895
- <K, V, A>(self: TxHashMap<K, V>, f: (value: V, key: K) => Option.Option<A>): Effect.Effect<TxHashMap<K, A>, never, Effect.Transaction>
2896
+ <K, V, A, X>(self: TxHashMap<K, V>, f: Filter.Filter<V, A, X, [key: K]>): Effect.Effect<TxHashMap<K, A>, never, Effect.Transaction>
2896
2897
  } = dual(
2897
2898
  2,
2898
- <K, V, A>(
2899
+ <K, V, A, X>(
2899
2900
  self: TxHashMap<K, V>,
2900
- f: (value: V, key: K) => Option.Option<A>
2901
+ f: Filter.Filter<V, A, X, [key: K]>
2901
2902
  ): Effect.Effect<TxHashMap<K, A>, never, Effect.Transaction> =>
2902
2903
  Effect.gen(function*() {
2903
2904
  const currentMap = yield* TxRef.get(self.ref)