@nicolastoulemont/std 0.6.0 → 0.7.1

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 (198) hide show
  1. package/README.md +232 -33
  2. package/dist/adt/index.d.mts +2 -2
  3. package/dist/adt/index.mjs +1 -1
  4. package/dist/adt-DajUZvJe.mjs +2 -0
  5. package/dist/adt-DajUZvJe.mjs.map +1 -0
  6. package/dist/brand/index.d.mts +2 -2
  7. package/dist/brand/index.mjs +1 -1
  8. package/dist/brand-Bia3Vj6l.mjs +2 -0
  9. package/dist/brand-Bia3Vj6l.mjs.map +1 -0
  10. package/dist/context/index.d.mts +2 -0
  11. package/dist/context/index.mjs +1 -0
  12. package/dist/context-CCHj1nab.mjs +2 -0
  13. package/dist/context-CCHj1nab.mjs.map +1 -0
  14. package/dist/context-r8ESJiFn.d.mts +176 -0
  15. package/dist/context-r8ESJiFn.d.mts.map +1 -0
  16. package/dist/data/index.d.mts +2 -2
  17. package/dist/data/index.mjs +1 -1
  18. package/dist/data-BLXO4XwS.mjs +2 -0
  19. package/dist/data-BLXO4XwS.mjs.map +1 -0
  20. package/dist/data.tagged-error.types-CGiKD-ES.d.mts +29 -0
  21. package/dist/data.tagged-error.types-CGiKD-ES.d.mts.map +1 -0
  22. package/dist/{discriminator.types-9PxvrZki.d.mts → discriminator.types-CTURejXz.d.mts} +1 -1
  23. package/dist/discriminator.types-CTURejXz.d.mts.map +1 -0
  24. package/dist/dual-CZhzZslG.mjs +2 -0
  25. package/dist/dual-CZhzZslG.mjs.map +1 -0
  26. package/dist/either/index.d.mts +2 -2
  27. package/dist/either/index.mjs +1 -1
  28. package/dist/either-BMLPfvMl.mjs +2 -0
  29. package/dist/either-BMLPfvMl.mjs.map +1 -0
  30. package/dist/{equality-CD4_A1Op.mjs → equality-CoyUHWh9.mjs} +1 -1
  31. package/dist/{equality-CD4_A1Op.mjs.map → equality-CoyUHWh9.mjs.map} +1 -1
  32. package/dist/{flow-CYjiodlC.mjs → flow-D8_tllWl.mjs} +1 -1
  33. package/dist/flow-D8_tllWl.mjs.map +1 -0
  34. package/dist/functions/index.d.mts +2 -0
  35. package/dist/functions/index.mjs +1 -0
  36. package/dist/functions-BkevX2Dw.mjs +2 -0
  37. package/dist/functions-BkevX2Dw.mjs.map +1 -0
  38. package/dist/fx/index.d.mts +2 -3
  39. package/dist/fx/index.mjs +1 -1
  40. package/dist/fx-K-a9Smhn.mjs +2 -0
  41. package/dist/fx-K-a9Smhn.mjs.map +1 -0
  42. package/dist/fx.runtime-DclEDyjY.mjs +2 -0
  43. package/dist/fx.runtime-DclEDyjY.mjs.map +1 -0
  44. package/dist/{fx.types-CDVjDn_3.mjs → fx.types-Bg-Mmdm5.mjs} +1 -1
  45. package/dist/fx.types-Bg-Mmdm5.mjs.map +1 -0
  46. package/dist/{fx.types-B34asVRX.d.mts → fx.types-DeEWEltG.d.mts} +2 -2
  47. package/dist/{fx.types-B34asVRX.d.mts.map → fx.types-DeEWEltG.d.mts.map} +1 -1
  48. package/dist/index-7Lv982Om.d.mts +217 -0
  49. package/dist/index-7Lv982Om.d.mts.map +1 -0
  50. package/dist/{index-CklRfom5.d.mts → index-B1-tBzc0.d.mts} +263 -368
  51. package/dist/index-B1-tBzc0.d.mts.map +1 -0
  52. package/dist/index-BNQ9xSAz.d.mts +464 -0
  53. package/dist/index-BNQ9xSAz.d.mts.map +1 -0
  54. package/dist/index-B_iY5tq0.d.mts +241 -0
  55. package/dist/index-B_iY5tq0.d.mts.map +1 -0
  56. package/dist/index-B_wWGszy.d.mts +129 -0
  57. package/dist/index-B_wWGszy.d.mts.map +1 -0
  58. package/dist/index-BiiE8NS7.d.mts +108 -0
  59. package/dist/index-BiiE8NS7.d.mts.map +1 -0
  60. package/dist/index-By6dNRc4.d.mts +277 -0
  61. package/dist/index-By6dNRc4.d.mts.map +1 -0
  62. package/dist/{index-BzYtgdX0.d.mts → index-CGiLfREk.d.mts} +123 -16
  63. package/dist/index-CGiLfREk.d.mts.map +1 -0
  64. package/dist/index-CUZn-ohG.d.mts +490 -0
  65. package/dist/index-CUZn-ohG.d.mts.map +1 -0
  66. package/dist/index-Cq2IFito.d.mts +121 -0
  67. package/dist/index-Cq2IFito.d.mts.map +1 -0
  68. package/dist/{index-B2l8_CiD.d.mts → index-DEAWPlcI.d.mts} +155 -216
  69. package/dist/index-DEAWPlcI.d.mts.map +1 -0
  70. package/dist/{index-C4v_3f3-.d.mts → index-DKS1g1oC.d.mts} +95 -42
  71. package/dist/index-DKS1g1oC.d.mts.map +1 -0
  72. package/dist/{index-jeC5jyRh.d.mts → index-DXbYlSnB.d.mts} +64 -101
  73. package/dist/index-DXbYlSnB.d.mts.map +1 -0
  74. package/dist/{index-CjZ95Dsv.d.mts → index-UzMbg1dh.d.mts} +188 -202
  75. package/dist/index-UzMbg1dh.d.mts.map +1 -0
  76. package/dist/index.d.mts +23 -16
  77. package/dist/index.mjs +1 -1
  78. package/dist/layer/index.d.mts +2 -0
  79. package/dist/layer/index.mjs +1 -0
  80. package/dist/layer-BttmtDrs.mjs +2 -0
  81. package/dist/layer-BttmtDrs.mjs.map +1 -0
  82. package/dist/layer.types-DgpCIsk_.d.mts +100 -0
  83. package/dist/layer.types-DgpCIsk_.d.mts.map +1 -0
  84. package/dist/multithread/index.d.mts +2 -0
  85. package/dist/multithread/index.mjs +1 -0
  86. package/dist/multithread-xUUh4eLn.mjs +19 -0
  87. package/dist/multithread-xUUh4eLn.mjs.map +1 -0
  88. package/dist/option/index.d.mts +2 -3
  89. package/dist/option/index.mjs +1 -1
  90. package/dist/option-Tfbo4wty.mjs +2 -0
  91. package/dist/option-Tfbo4wty.mjs.map +1 -0
  92. package/dist/option.types-D1mm0zUb.mjs +2 -0
  93. package/dist/option.types-D1mm0zUb.mjs.map +1 -0
  94. package/dist/{option.types-ClJiBTdg.d.mts → option.types-qPevEZQd.d.mts} +7 -12
  95. package/dist/option.types-qPevEZQd.d.mts.map +1 -0
  96. package/dist/order/index.d.mts +2 -0
  97. package/dist/order/index.mjs +1 -0
  98. package/dist/order-D5c4QChk.mjs +2 -0
  99. package/dist/order-D5c4QChk.mjs.map +1 -0
  100. package/dist/pipeable-COGyGMUV.mjs +2 -0
  101. package/dist/pipeable-COGyGMUV.mjs.map +1 -0
  102. package/dist/{pipeable-B4YJA56p.d.mts → pipeable-rfqacPxZ.d.mts} +2 -9
  103. package/dist/{pipeable-B4YJA56p.d.mts.map → pipeable-rfqacPxZ.d.mts.map} +1 -1
  104. package/dist/predicate/index.d.mts +2 -2
  105. package/dist/predicate/index.mjs +1 -1
  106. package/dist/predicate-DUhhQqWY.mjs +2 -0
  107. package/dist/predicate-DUhhQqWY.mjs.map +1 -0
  108. package/dist/provide/index.d.mts +2 -0
  109. package/dist/provide/index.mjs +1 -0
  110. package/dist/provide-C2cWOx2B.mjs +2 -0
  111. package/dist/provide-C2cWOx2B.mjs.map +1 -0
  112. package/dist/queue/index.d.mts +2 -0
  113. package/dist/queue/index.mjs +1 -0
  114. package/dist/queue-Sg6KJerl.mjs +2 -0
  115. package/dist/queue-Sg6KJerl.mjs.map +1 -0
  116. package/dist/queue.types-CD2LOu37.d.mts +36 -0
  117. package/dist/queue.types-CD2LOu37.d.mts.map +1 -0
  118. package/dist/result/index.d.mts +2 -3
  119. package/dist/result/index.mjs +1 -1
  120. package/dist/result-BEzV0DYC.mjs +2 -0
  121. package/dist/result-BEzV0DYC.mjs.map +1 -0
  122. package/dist/{result.types-HHDzgSTV.d.mts → result.types-_xDAei3-.d.mts} +5 -97
  123. package/dist/result.types-_xDAei3-.d.mts.map +1 -0
  124. package/dist/schedule/index.d.mts +2 -0
  125. package/dist/schedule/index.mjs +1 -0
  126. package/dist/schedule-C6tjcJ1O.mjs +2 -0
  127. package/dist/schedule-C6tjcJ1O.mjs.map +1 -0
  128. package/dist/schedule-DlX2Dg69.d.mts +144 -0
  129. package/dist/schedule-DlX2Dg69.d.mts.map +1 -0
  130. package/dist/scope/index.d.mts +2 -0
  131. package/dist/scope/index.mjs +1 -0
  132. package/dist/scope-CZdp4wKX.d.mts +79 -0
  133. package/dist/scope-CZdp4wKX.d.mts.map +1 -0
  134. package/dist/scope-D_kzd1nT.mjs +2 -0
  135. package/dist/scope-D_kzd1nT.mjs.map +1 -0
  136. package/dist/service/index.d.mts +2 -0
  137. package/dist/service/index.mjs +1 -0
  138. package/dist/service-3PYQTUdH.mjs +2 -0
  139. package/dist/service-3PYQTUdH.mjs.map +1 -0
  140. package/dist/service-DrXU7KJG.d.mts +69 -0
  141. package/dist/service-DrXU7KJG.d.mts.map +1 -0
  142. package/dist/service-resolution-C19smeaO.mjs +2 -0
  143. package/dist/service-resolution-C19smeaO.mjs.map +1 -0
  144. package/package.json +50 -12
  145. package/dist/adt-CkRcY_GA.mjs +0 -2
  146. package/dist/adt-CkRcY_GA.mjs.map +0 -1
  147. package/dist/apply-fn.types-0g_9eXRy.d.mts +0 -8
  148. package/dist/apply-fn.types-0g_9eXRy.d.mts.map +0 -1
  149. package/dist/brand-Gy0kW6-n.mjs +0 -2
  150. package/dist/brand-Gy0kW6-n.mjs.map +0 -1
  151. package/dist/data-C0_3MGwm.mjs +0 -2
  152. package/dist/data-C0_3MGwm.mjs.map +0 -1
  153. package/dist/discriminator.types-9PxvrZki.d.mts.map +0 -1
  154. package/dist/either-CPzK-s8W.mjs +0 -2
  155. package/dist/either-CPzK-s8W.mjs.map +0 -1
  156. package/dist/err/index.d.mts +0 -2
  157. package/dist/err/index.mjs +0 -1
  158. package/dist/err-3KpQ4pj9.mjs +0 -2
  159. package/dist/err-3KpQ4pj9.mjs.map +0 -1
  160. package/dist/flow/index.d.mts +0 -2
  161. package/dist/flow/index.mjs +0 -1
  162. package/dist/flow-CYjiodlC.mjs.map +0 -1
  163. package/dist/fx-vqywVJhV.mjs +0 -2
  164. package/dist/fx-vqywVJhV.mjs.map +0 -1
  165. package/dist/fx.types-CDVjDn_3.mjs.map +0 -1
  166. package/dist/index-8Ne4GdOG.d.mts +0 -288
  167. package/dist/index-8Ne4GdOG.d.mts.map +0 -1
  168. package/dist/index-B2l8_CiD.d.mts.map +0 -1
  169. package/dist/index-BOrJQBPO.d.mts +0 -80
  170. package/dist/index-BOrJQBPO.d.mts.map +0 -1
  171. package/dist/index-BsXtpnw-.d.mts +0 -225
  172. package/dist/index-BsXtpnw-.d.mts.map +0 -1
  173. package/dist/index-BzYtgdX0.d.mts.map +0 -1
  174. package/dist/index-C4v_3f3-.d.mts.map +0 -1
  175. package/dist/index-CjZ95Dsv.d.mts.map +0 -1
  176. package/dist/index-CklRfom5.d.mts.map +0 -1
  177. package/dist/index-DZdmFtjA.d.mts +0 -79
  178. package/dist/index-DZdmFtjA.d.mts.map +0 -1
  179. package/dist/index-a4MEBZZ1.d.mts +0 -850
  180. package/dist/index-a4MEBZZ1.d.mts.map +0 -1
  181. package/dist/index-jeC5jyRh.d.mts.map +0 -1
  182. package/dist/option-DawZC1cE.mjs +0 -2
  183. package/dist/option-DawZC1cE.mjs.map +0 -1
  184. package/dist/option.types-ClJiBTdg.d.mts.map +0 -1
  185. package/dist/pipe/index.d.mts +0 -2
  186. package/dist/pipe/index.mjs +0 -1
  187. package/dist/pipe-BPpJyZf7.mjs +0 -2
  188. package/dist/pipe-BPpJyZf7.mjs.map +0 -1
  189. package/dist/pipeable-BA0mXhs4.mjs +0 -2
  190. package/dist/pipeable-BA0mXhs4.mjs.map +0 -1
  191. package/dist/predicate-Cy_oHA1Q.mjs +0 -2
  192. package/dist/predicate-Cy_oHA1Q.mjs.map +0 -1
  193. package/dist/result-CgGYLp0L.mjs +0 -2
  194. package/dist/result-CgGYLp0L.mjs.map +0 -1
  195. package/dist/result.types-HHDzgSTV.d.mts.map +0 -1
  196. /package/dist/{chunk-DAexk1S7.mjs → chunk-C934ptG5.mjs} +0 -0
  197. /package/dist/{option-Bb-taghv.mjs → option-CBCwzF0L.mjs} +0 -0
  198. /package/dist/{result-fiJhwVGz.mjs → result-B5WbPg8C.mjs} +0 -0
@@ -1,9 +1,49 @@
1
- import { a as OptionFilter, c as OptionMatch, d as OptionUnwrapOr, f as OptionUnwrapOrElse, i as OptionAll, l as OptionOrElse, o as OptionFlatMap, r as Option$1, s as OptionMap, t as FromTryReturn, u as OptionTap } from "./option.types-ClJiBTdg.mjs";
1
+ import { a as OptionFilter, c as OptionMatch, d as OptionUnwrapOr, f as OptionUnwrapOrElse, i as OptionAll, l as OptionOrElse, n as NoSuchElementError$1, o as OptionFlatMap, r as Option$1, s as OptionMap, t as FromTryReturn, u as OptionTap } from "./option.types-qPevEZQd.mjs";
2
2
 
3
3
  //#region src/option/option.d.ts
4
4
  declare namespace option_d_exports {
5
- export { Option, all, filter, flatMap, fromNullable, fromTry, isNone, isSome, map, match, none, orElse, some, tap, unwrapOr, unwrapOrElse };
5
+ export { NoSuchElementError, Option, all, filter, flatMap, fromNullable, fromTry, isNone, isSome, map, match, none, orElse, some, tap, unwrapOr, unwrapOrElse };
6
6
  }
7
+ /**
8
+ * Re-exported error type used when yielding `Option.none()` in `Fx.gen`.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Option } from "@nicolastoulemont/std"
13
+ *
14
+ * const error = new Option.NoSuchElementError()
15
+ * // => error.name === "NoSuchElementError"
16
+ * ```
17
+ *
18
+ * @category Re-exports
19
+ */
20
+ declare const NoSuchElementError: typeof NoSuchElementError$1;
21
+ /**
22
+ * Re-exported `NoSuchElementError` instance type.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import type { Option } from "@nicolastoulemont/std"
27
+ *
28
+ * type Example = Option.NoSuchElementError
29
+ * ```
30
+ *
31
+ * @category Re-exports
32
+ */
33
+ type NoSuchElementError = InstanceType<typeof NoSuchElementError$1>;
34
+ /**
35
+ * Re-exported `Option` type.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import type { Option } from "@nicolastoulemont/std"
40
+ *
41
+ * type Example = Option.Option<unknown>
42
+ * ```
43
+ *
44
+ * @category Re-exports
45
+ */
46
+ type Option<T> = Option$1<T>;
7
47
  /**
8
48
  * Create an Option with a value.
9
49
  *
@@ -12,8 +52,13 @@ declare namespace option_d_exports {
12
52
  *
13
53
  * @example
14
54
  * ```ts
15
- * some(42) // { _tag: "Some", value: 42 }
55
+ * import { Option } from "@nicolastoulemont/std"
56
+ *
57
+ * const value = Option.some(42)
58
+ * // => { _tag: "Some", value: 42 }
16
59
  * ```
60
+ *
61
+ * @category Constructors
17
62
  */
18
63
  declare const some: <T>(value: T) => Option$1<T>;
19
64
  /**
@@ -23,8 +68,13 @@ declare const some: <T>(value: T) => Option$1<T>;
23
68
  *
24
69
  * @example
25
70
  * ```ts
26
- * none() // { _tag: "None" }
71
+ * import { Option } from "@nicolastoulemont/std"
72
+ *
73
+ * const value = Option.none<number>()
74
+ * // => { _tag: "None" }
27
75
  * ```
76
+ *
77
+ * @category Constructors
28
78
  */
29
79
  declare const none: <T = never>() => Option$1<T>;
30
80
  /**
@@ -35,15 +85,30 @@ declare const none: <T = never>() => Option$1<T>;
35
85
  *
36
86
  * @example
37
87
  * ```ts
38
- * const option = some(42)
39
- * if (isSome(option)) {
40
- * console.log(option.value) // TypeScript knows value exists
41
- * }
88
+ * import { Option } from "@nicolastoulemont/std"
89
+ *
90
+ * const value = Option.isSome(Option.some(1))
91
+ * // => true
42
92
  * ```
93
+ *
94
+ * @category Guards
43
95
  */
44
96
  declare const isSome: <T>(option: Option$1<T>) => option is Extract<Option$1<T>, {
45
97
  _tag: "Some";
46
98
  }>;
99
+ /**
100
+ * isNone utility.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { Option } from "@nicolastoulemont/std"
105
+ *
106
+ * const value = Option.isNone(Option.none())
107
+ * // => true
108
+ * ```
109
+ *
110
+ * @category Guards
111
+ */
47
112
  declare const isNone: <T>(option: Option$1<T>) => option is Extract<Option$1<T>, {
48
113
  _tag: "None";
49
114
  }>;
@@ -64,21 +129,17 @@ declare const isNone: <T>(option: Option$1<T>) => option is Extract<Option$1<T>,
64
129
  *
65
130
  * @example
66
131
  * ```ts
67
- * // Data-first (direct call)
68
- * map(some(5), n => n * 2) // { _tag: "Some", value: 10 }
69
- *
70
- * // Data-last (curried for pipe)
71
- * pipe(
72
- * some(5),
73
- * map(n => n * 2)
74
- * ) // { _tag: "Some", value: 10 }
75
- *
76
- * // Async usage
77
- * await pipe(
78
- * some(userId),
79
- * map(async id => await fetchName(id))
80
- * ) // Promise<Option<string>>
132
+ * import { Option } from "@nicolastoulemont/std"
133
+ *
134
+ * const input = Option.some(2)
135
+ * const dataFirst = Option.map(input, (n) => n + 1)
136
+ * // => { _tag: "Some", value: 3 }
137
+ *
138
+ * const dataLast = Option.map((n: number) => n + 1)(input)
139
+ * // => { _tag: "Some", value: 3 }
81
140
  * ```
141
+ *
142
+ * @category Mapping
82
143
  */
83
144
  declare const map: OptionMap;
84
145
  /**
@@ -98,25 +159,17 @@ declare const map: OptionMap;
98
159
  *
99
160
  * @example
100
161
  * ```ts
101
- * const findUser = (id: number) =>
102
- * id > 0 ? some({ id, name: 'Alice' }) : none()
103
- *
104
- * // Data-first (direct call)
105
- * flatMap(some(10), id => findUser(id))
106
- * // { _tag: "Some", value: { id: 10, name: 'Alice' } }
107
- *
108
- * // Data-last (curried for pipe)
109
- * pipe(
110
- * some(10),
111
- * flatMap(id => findUser(id))
112
- * ) // { _tag: "Some", value: { id: 10, name: 'Alice' } }
113
- *
114
- * // Async usage
115
- * await pipe(
116
- * some(userId),
117
- * flatMap(async id => some(await fetchUser(id)))
118
- * ) // Promise<Option<User>>
162
+ * import { Option } from "@nicolastoulemont/std"
163
+ *
164
+ * const input = Option.some(2)
165
+ * const dataFirst = Option.flatMap(input, (n) => Option.some(n + 1))
166
+ * // => { _tag: "Some", value: 3 }
167
+ *
168
+ * const dataLast = Option.flatMap((n: number) => Option.some(n + 1))(input)
169
+ * // => { _tag: "Some", value: 3 }
119
170
  * ```
171
+ *
172
+ * @category Sequencing
120
173
  */
121
174
  declare const flatMap: OptionFlatMap;
122
175
  /**
@@ -137,23 +190,22 @@ declare const flatMap: OptionFlatMap;
137
190
  *
138
191
  * @example
139
192
  * ```ts
140
- * // Data-first (direct call)
141
- * tap(some(42), console.log) // logs 42, returns { _tag: "Some", value: 42 }
142
- *
143
- * // Data-last (curried for pipe)
144
- * pipe(
145
- * some(42),
146
- * tap(console.log), // logs 42
147
- * map(n => n * 2)
148
- * ) // { _tag: "Some", value: 84 }
149
- *
150
- * // Async usage
151
- * await pipe(
152
- * some(42),
153
- * tap(async v => await logToServer(v)),
154
- * map(n => n * 2)
155
- * ) // Promise<Option<84>>
193
+ * import { Option } from "@nicolastoulemont/std"
194
+ *
195
+ * let seen = 0
196
+ * const input = Option.some(2)
197
+ * const dataFirst = Option.tap(input, (n) => {
198
+ * seen = n
199
+ * })
200
+ * // => { _tag: "Some", value: 2 }
201
+ *
202
+ * const dataLast = Option.tap((n: number) => {
203
+ * seen = n
204
+ * })(input)
205
+ * // => { _tag: "Some", value: 2 }
156
206
  * ```
207
+ *
208
+ * @category Sequencing
157
209
  */
158
210
  declare const tap: OptionTap;
159
211
  /**
@@ -173,30 +225,17 @@ declare const tap: OptionTap;
173
225
  *
174
226
  * @example
175
227
  * ```ts
176
- * // Data-first (direct call)
177
- * orElse(none(), () => some(defaultValue))
178
- * // { _tag: "Some", value: defaultValue }
179
- *
180
- * // Data-last (curried for pipe)
181
- * pipe(
182
- * none(),
183
- * orElse(() => some(defaultValue))
184
- * ) // { _tag: "Some", value: defaultValue }
185
- *
186
- * // Async recovery
187
- * await pipe(
188
- * none(),
189
- * orElse(async () => some(await fetchFromAPI()))
190
- * ) // Promise<Option<T>>
191
- *
192
- * // Chain multiple fallbacks
193
- * pipe(
194
- * none(),
195
- * orElse(() => tryCache()),
196
- * orElse(() => tryAPI()),
197
- * orElse(() => some(fallback))
198
- * )
228
+ * import { Option } from "@nicolastoulemont/std"
229
+ *
230
+ * const input = Option.none<number>()
231
+ * const dataFirst = Option.orElse(input, () => Option.some(0))
232
+ * // => { _tag: "Some", value: 0 }
233
+ *
234
+ * const dataLast = Option.orElse(() => Option.some(0))(input)
235
+ * // => { _tag: "Some", value: 0 }
199
236
  * ```
237
+ *
238
+ * @category Combining
200
239
  */
201
240
  declare const orElse: OptionOrElse;
202
241
  /**
@@ -213,26 +252,17 @@ declare const orElse: OptionOrElse;
213
252
  *
214
253
  * @example
215
254
  * ```ts
216
- * // Data-first (direct call)
217
- * filter(some(5), n => n > 10) // { _tag: "None" }
218
- *
219
- * // Data-last (curried for pipe)
220
- * pipe(
221
- * some(5),
222
- * filter(n => n > 10)
223
- * ) // { _tag: "None" }
224
- *
225
- * pipe(
226
- * some(15),
227
- * filter(n => n > 10)
228
- * ) // { _tag: "Some", value: 15 }
229
- *
230
- * // With complex validation
231
- * pipe(
232
- * some(user),
233
- * filter(u => u.age >= 18)
234
- * )
255
+ * import { Option } from "@nicolastoulemont/std"
256
+ *
257
+ * const input = Option.some(3)
258
+ * const dataFirst = Option.filter(input, (n) => n > 0)
259
+ * // => { _tag: "Some", value: 3 }
260
+ *
261
+ * const dataLast = Option.filter((n: number) => n > 0)(input)
262
+ * // => { _tag: "Some", value: 3 }
235
263
  * ```
264
+ *
265
+ * @category Filtering
236
266
  */
237
267
  declare const filter: OptionFilter;
238
268
  /**
@@ -247,18 +277,13 @@ declare const filter: OptionFilter;
247
277
  *
248
278
  * @example
249
279
  * ```ts
250
- * // Array form - tuple types inferred automatically for up to 6 elements
251
- * const [num, str] = pipe(
252
- * Option.all([parseNumber(input), parseString(other)]),
253
- * Option.unwrapOr([0, ''])
254
- * )
255
- *
256
- * // Object form - returns Option<{ user: User, config: Config }>
257
- * pipe(
258
- * Option.all({ user: findUser(id), config: loadConfig() }),
259
- * Option.tap(({ user, config }) => console.log(user.name, config.theme))
260
- * )
280
+ * import { Option } from "@nicolastoulemont/std"
281
+ *
282
+ * const combined = Option.all([Option.some(1), Option.some(2)] as const)
283
+ * // => { _tag: "Some", value: [1, 2] }
261
284
  * ```
285
+ *
286
+ * @category Combining
262
287
  */
263
288
  declare const all: OptionAll;
264
289
  /**
@@ -275,14 +300,17 @@ declare const all: OptionAll;
275
300
  *
276
301
  * @example
277
302
  * ```ts
278
- * // Data-first (direct call)
279
- * unwrapOr(some(42), 0) // 42
280
- * unwrapOr(none(), 0) // 0
303
+ * import { Option } from "@nicolastoulemont/std"
304
+ *
305
+ * const input = Option.none<number>()
306
+ * const dataFirst = Option.unwrapOr(input, 0)
307
+ * // => 0
281
308
  *
282
- * // Data-last (curried for pipe)
283
- * pipe(some(42), unwrapOr(0)) // 42
284
- * pipe(none(), unwrapOr(0)) // 0
309
+ * const dataLast = Option.unwrapOr(0)(input)
310
+ * // => 0
285
311
  * ```
312
+ *
313
+ * @category Getters
286
314
  */
287
315
  declare const unwrapOr: OptionUnwrapOr;
288
316
  /**
@@ -297,15 +325,17 @@ declare const unwrapOr: OptionUnwrapOr;
297
325
  *
298
326
  * @example
299
327
  * ```ts
300
- * // Data-first (direct call)
301
- * unwrapOrElse(none(), () => generateDefault()) // generateDefault()
302
- *
303
- * // Data-last (curried for pipe)
304
- * pipe(
305
- * none(),
306
- * unwrapOrElse(() => generateDefault())
307
- * ) // generateDefault()
328
+ * import { Option } from "@nicolastoulemont/std"
329
+ *
330
+ * const input = Option.none<number>()
331
+ * const dataFirst = Option.unwrapOrElse(input, () => 0)
332
+ * // => 0
333
+ *
334
+ * const dataLast = Option.unwrapOrElse(() => 0)(input)
335
+ * // => 0
308
336
  * ```
337
+ *
338
+ * @category Getters
309
339
  */
310
340
  declare const unwrapOrElse: OptionUnwrapOrElse;
311
341
  /**
@@ -320,23 +350,38 @@ declare const unwrapOrElse: OptionUnwrapOrElse;
320
350
  *
321
351
  * @example
322
352
  * ```ts
323
- * // Data-first (direct call)
324
- * match(some(42), {
325
- * Some: n => `Got ${n}`,
326
- * None: () => 'No value'
327
- * }) // 'Got 42'
328
- *
329
- * // Data-last (curried for pipe)
330
- * pipe(
331
- * some(42),
332
- * match({
333
- * Some: n => `Got ${n}`,
334
- * None: () => 'No value'
335
- * })
336
- * ) // 'Got 42'
353
+ * import { Option } from "@nicolastoulemont/std"
354
+ *
355
+ * const input = Option.some(2)
356
+ * const dataFirst = Option.match(input, {
357
+ * Some: (value) => `some:${value}` ,
358
+ * None: () => "none" ,
359
+ * })
360
+ * // => "some:2"
361
+ *
362
+ * const dataLast = Option.match({
363
+ * Some: (value: number) => `some:${value}` ,
364
+ * None: () => "none" ,
365
+ * })(input)
366
+ * // => "some:2"
337
367
  * ```
368
+ *
369
+ * @category Pattern Matching
338
370
  */
339
371
  declare const match: OptionMatch;
372
+ /**
373
+ * fromNullable utility.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * import { Option } from "@nicolastoulemont/std"
378
+ *
379
+ * const value = Option.fromNullable("Ada")
380
+ * // => { _tag: "Some", value: "Ada" }
381
+ * ```
382
+ *
383
+ * @category Conversions
384
+ */
340
385
  declare const fromNullable: <T>(value: T) => Option$1<NonNullable<T>>;
341
386
  /**
342
387
  * Wrap a function that might throw into an Option.
@@ -356,74 +401,15 @@ declare const fromNullable: <T>(value: T) => Option$1<NonNullable<T>>;
356
401
  *
357
402
  * @example
358
403
  * ```ts
359
- * // Sync usage
360
- * fromTry(() => JSON.parse('{"valid": true}'))
361
- * // { _tag: "Some", value: { valid: true } }
362
- *
363
- * fromTry(() => JSON.parse('not json'))
364
- * // { _tag: "None" }
365
- *
366
- * // When fn returns `any`, add explicit return type:
367
- * fromTry((): unknown => JSON.parse(input))
368
- * fromTry((): MyType => JSON.parse(input))
369
- *
370
- * // Async usage
371
- * await fromTry(async () => await fetch('/api/user'))
372
- * // Promise<Option<Response>>
404
+ * import { Option } from "@nicolastoulemont/std"
373
405
  *
374
- * await fromTry(async () => {
375
- * throw new Error('network error')
376
- * })
377
- * // Promise<{ _tag: "None" }>
406
+ * const parsed = Option.fromTry(() => Number.parseInt("42", 10))
407
+ * // => { _tag: "Some", value: 42 }
378
408
  * ```
379
- */
380
- declare const fromTry: <T>(fn: () => T) => FromTryReturn<T>;
381
- /**
382
- * Option namespace containing all utility functions for working with Option types.
383
- *
384
- * Option represents either the presence (some) or absence (none) of a value.
385
- * Use this for optional values without needing to track why the value is missing.
386
409
  *
387
- * @see {@link Result} for success/failure with error information
388
- * @see {@link Either} for two valid outcomes
389
- *
390
- * @example
391
- * ```ts
392
- * import { Option, pipe } from '@nicolastoulemont/std'
393
- * import type { Option as OptionType } from '@nicolastoulemont/std'
394
- *
395
- * const findUser = (id: number): OptionType<User> =>
396
- * id > 0 ? Option.some({ id, name: 'Alice' }) : Option.none()
397
- *
398
- * const result = pipe(
399
- * Option.some(10),
400
- * Option.flatMap(findUser),
401
- * Option.map(user => user.name),
402
- * Option.unwrapOr('Unknown')
403
- * )
404
- * ```
410
+ * @category Conversions
405
411
  */
406
- declare const Option: {
407
- readonly some: <T>(value: T) => Option$1<T>;
408
- readonly none: <T = never>() => Option$1<T>;
409
- readonly isSome: <T>(option: Option$1<T>) => option is Extract<Option$1<T>, {
410
- _tag: "Some";
411
- }>;
412
- readonly isNone: <T>(option: Option$1<T>) => option is Extract<Option$1<T>, {
413
- _tag: "None";
414
- }>;
415
- readonly map: OptionMap;
416
- readonly flatMap: OptionFlatMap;
417
- readonly tap: OptionTap;
418
- readonly orElse: OptionOrElse;
419
- readonly filter: OptionFilter;
420
- readonly all: OptionAll;
421
- readonly unwrapOr: OptionUnwrapOr;
422
- readonly unwrapOrElse: OptionUnwrapOrElse;
423
- readonly match: OptionMatch;
424
- readonly fromNullable: <T>(value: T) => Option$1<NonNullable<T>>;
425
- readonly fromTry: <T>(fn: () => T) => FromTryReturn<T>;
426
- };
412
+ declare const fromTry: <T>(fn: () => T) => FromTryReturn<T>;
427
413
  //#endregion
428
414
  export { option_d_exports as t };
429
- //# sourceMappingURL=index-CjZ95Dsv.d.mts.map
415
+ //# sourceMappingURL=index-UzMbg1dh.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-UzMbg1dh.d.mts","names":[],"sources":["../src/option/option.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;cA4Da,2BAAkB;;;;;;;;AAA/B;AAcA;AAcA;AAwBA;;AAA8C,KAtClC,kBAAA,GAAqB,YAsCa,CAAA,OAtCO,oBAsCP,CAAA;;;AA8B9C;AAkCA;;;;;;;AAgBA;;AAAkC,KAxGtB,MAwGsB,CAAA,CAAA,CAAA,GAxGV,QAwGU,CAxGC,CAwGD,CAAA;;;;;AAqClC;AAwCA;AAwCA;AAwCA;AA8BA;AA8BA;AAkDA;AA6BA;AAmCA;AA2CA;;;AAAsD,cAtczC,IAscyC,EAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAtcvB,CAscuB,EAAA,GAtcnB,QAscmB,CAtcR,CAscQ,CAAA;;;AA6BtD;;;;;;;;;;;;;cArca,uBAAsB,SAAW;;;;;;;;;;;;;;;;;cAkCjC,oBAAqB,SAAW,iBAAe,QAAQ,SAAW;;;;;;;;;;;;;;;;cAgBlE,oBAAqB,SAAW,iBAAe,QAAQ,SAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqClE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCL,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCT,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCL,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BR,QAAQ;;;;;;;;;;;;;;;;;;;;;cA8BR,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkDL,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;cA6BV,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmCd,OAAO;;;;;;;;;;;;;;cA2CP,yBAA0B,MAAI,SAAW,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6BrD,uBAAwB,MAAI,cAAc"}
package/dist/index.d.mts CHANGED
@@ -1,16 +1,23 @@
1
- import { a as AdtCodecError, c as AdtInferInput, d as AdtValidationError, f as AdtVariant, g as AdtMatchHandlers, h as AdtVariantOf, i as AdtCodecDef, l as AdtInferOutput, m as AdtVariantNames, n as Adt, o as AdtExtractSchema, p as AdtVariantDef, r as AdtCodecConstraint, s as AdtInfer, u as AdtUnion } from "./index-C4v_3f3-.mjs";
2
- import { a as FxError, i as Fx$1, l as FxValue, m as SyncFx, p as ServiceRequest, s as FxRequirements, t as AsyncFx } from "./fx.types-B34asVRX.mjs";
3
- import { n as pipeMethod, t as Pipeable } from "./pipeable-B4YJA56p.mjs";
4
- import { A as NoUnion, C as IsAny, D as Last, E as KeysOfType, F as Prettify, I as RequiredKeys, L as Tail, M as OmitByType, N as PartialKeys, O as Length, P as PickByType, R as UnionToIntersection, S as Init, T as IsUnknown, _ as DeepReadonly, g as DeepPrettify, h as DeepPartial, k as Merge, m as DeepMutable, p as AsyncReturnType, t as Result$1, v as DeepRequired, w as IsNever, x as Head, y as Equals } from "./result.types-HHDzgSTV.mjs";
5
- import { c as BrandKey, d as Unbrand, o as Brand$1, s as BrandError, t as Brand, u as Branded } from "./index-jeC5jyRh.mjs";
6
- import { a as TaggedValue, i as TaggedConstructor, n as ArrayValue, o as TupleValue, r as StructValue, t as Data } from "./index-BzYtgdX0.mjs";
7
- import { r as Option } from "./option.types-ClJiBTdg.mjs";
8
- import { O as Either$1, t as Either } from "./index-CklRfom5.mjs";
9
- import { a as ErrorData, c as TaggedErrorFactory, l as TaggedErrorInstance, n as TaggedError, o as ErrorTag, s as TaggedError$1, t as Err } from "./index-BsXtpnw-.mjs";
10
- import { t as flow } from "./index-BOrJQBPO.mjs";
11
- import { t as option_d_exports } from "./index-CjZ95Dsv.mjs";
12
- import { t as pipe } from "./index-DZdmFtjA.mjs";
13
- import { E as TaggedMatch, F as Unify, I as UnifyEither, L as UnifyFx, N as Defect, P as Exit, R as UnifyOption, S as ServiceOf, T as Fx, a as Layer$1, b as ServiceClass, c as LayerROut, g as ScopeTag, h as ScopeService, i as Layer, n as provideContext, o as LayerError, r as provideService, s as LayerRIn, t as provide, v as Context, w as serviceTag, y as Service, z as UnifyResult } from "./index-a4MEBZZ1.mjs";
14
- import { f as Predicate$1, p as Refinement, t as Predicate } from "./index-8Ne4GdOG.mjs";
15
- import { t as Result } from "./index-B2l8_CiD.mjs";
16
- export { Adt, AdtCodecConstraint, AdtCodecDef, AdtCodecError, AdtExtractSchema, AdtInfer, AdtInferInput, AdtInferOutput, AdtMatchHandlers, AdtUnion, AdtValidationError, AdtVariant, AdtVariantDef, AdtVariantNames, AdtVariantOf, ArrayValue, AsyncFx, AsyncReturnType, Brand, BrandError, BrandKey, Brand$1 as BrandType, Branded, Context, Context as ContextType, Data, DeepMutable, DeepPartial, DeepPrettify, DeepReadonly, DeepRequired, Either, Either$1 as EitherType, Equals, Err, ErrorData, ErrorTag, Exit, Exit as ExitType, Defect as ExitDefect, Fx, FxError, FxRequirements, Fx$1 as FxType, FxValue, Head, Init, IsAny, IsNever, IsUnknown, KeysOfType, Last, Layer, LayerError, LayerRIn, LayerROut, Layer$1 as LayerType, Length, Merge, NoUnion, OmitByType, option_d_exports as Option, Option as OptionType, PartialKeys, PickByType, Pipeable, Predicate, Predicate$1 as PredicateType, Prettify, Refinement, RequiredKeys, Result, Result$1 as ResultType, ScopeTag as Scope, ScopeService, Service, ServiceClass, ServiceOf, ServiceRequest, StructValue, SyncFx, TaggedConstructor, TaggedError, TaggedErrorFactory, TaggedErrorInstance, TaggedError$1 as TaggedErrorType, TaggedMatch, TaggedValue, Tail, TupleValue, Unbrand, Unify, UnifyEither, UnifyFx, UnifyOption, UnifyResult, UnionToIntersection, flow, pipe, pipeMethod, provide, provideContext, provideService, serviceTag };
1
+ import { t as adt_d_exports } from "./index-DKS1g1oC.mjs";
2
+ import { t as brand_d_exports } from "./index-DXbYlSnB.mjs";
3
+ import { n as service_d_exports } from "./service-DrXU7KJG.mjs";
4
+ import { n as context_d_exports } from "./context-r8ESJiFn.mjs";
5
+ import "./context/index.mjs";
6
+ import { t as data_d_exports } from "./index-CGiLfREk.mjs";
7
+ import { t as either_d_exports } from "./index-B1-tBzc0.mjs";
8
+ import { n as flow, t as pipe } from "./index-B_wWGszy.mjs";
9
+ import { r as schedule_d_exports } from "./schedule-DlX2Dg69.mjs";
10
+ import { t as fx_d_exports } from "./index-BNQ9xSAz.mjs";
11
+ import { r as scope_d_exports } from "./scope-CZdp4wKX.mjs";
12
+ import { t as layer_d_exports } from "./index-7Lv982Om.mjs";
13
+ import { t as multithread_d_exports } from "./index-By6dNRc4.mjs";
14
+ import { t as option_d_exports } from "./index-UzMbg1dh.mjs";
15
+ import { t as order_d_exports } from "./index-CUZn-ohG.mjs";
16
+ import { t as predicate_d_exports } from "./index-B_iY5tq0.mjs";
17
+ import { t as provide_d_exports } from "./index-BiiE8NS7.mjs";
18
+ import { t as queue_d_exports } from "./index-Cq2IFito.mjs";
19
+ import { t as result_d_exports } from "./index-DEAWPlcI.mjs";
20
+ import "./schedule/index.mjs";
21
+ import "./scope/index.mjs";
22
+ import "./service/index.mjs";
23
+ export { adt_d_exports as Adt, brand_d_exports as Brand, context_d_exports as Context, data_d_exports as Data, either_d_exports as Either, fx_d_exports as Fx, layer_d_exports as Layer, multithread_d_exports as Multithread, option_d_exports as Option, order_d_exports as Order, predicate_d_exports as Predicate, provide_d_exports as Provide, queue_d_exports as Queue, result_d_exports as Result, schedule_d_exports as Schedule, scope_d_exports as Scope, service_d_exports as Service, flow, pipe };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./adt-CkRcY_GA.mjs";import{t}from"./pipeable-BA0mXhs4.mjs";import{t as n}from"./flow-CYjiodlC.mjs";import{t as r}from"./result-CgGYLp0L.mjs";import{t as i}from"./brand-Gy0kW6-n.mjs";import{t as a}from"./data-C0_3MGwm.mjs";import{r as o}from"./option-DawZC1cE.mjs";import{t as s}from"./either-CPzK-s8W.mjs";import{n as c,t as l}from"./err-3KpQ4pj9.mjs";import"./flow/index.mjs";import{t as u}from"./pipe-BPpJyZf7.mjs";import{t as d}from"./predicate-Cy_oHA1Q.mjs";import{b as f,c as p,f as m,l as h,n as g,o as _,p as v,r as y,t as b,u as x}from"./fx-vqywVJhV.mjs";export{e as Adt,i as Brand,h as Context,a as Data,s as Either,l as Err,f as Exit,v as Fx,p as Layer,o as Option,d as Predicate,r as Result,_ as Scope,x as Service,c as TaggedError,n as flow,u as pipe,t as pipeMethod,b as provide,g as provideContext,y as provideService,m as serviceTag};
1
+ import{t as e}from"./adt-DajUZvJe.mjs";import{t}from"./flow-D8_tllWl.mjs";import{i as n}from"./result-BEzV0DYC.mjs";import{t as r}from"./brand-Bia3Vj6l.mjs";import{t as i}from"./context-CCHj1nab.mjs";import"./context/index.mjs";import{n as a}from"./data-BLXO4XwS.mjs";import{r as o}from"./option-Tfbo4wty.mjs";import{t as s}from"./either-BMLPfvMl.mjs";import{t as c}from"./functions-BkevX2Dw.mjs";import{a as l}from"./queue-Sg6KJerl.mjs";import{t as u}from"./fx-K-a9Smhn.mjs";import{t as d}from"./layer-BttmtDrs.mjs";import{t as f}from"./multithread-xUUh4eLn.mjs";import{t as p}from"./order-D5c4QChk.mjs";import{t as m}from"./predicate-DUhhQqWY.mjs";import{n as h}from"./scope-D_kzd1nT.mjs";import{t as g}from"./provide-C2cWOx2B.mjs";import"./queue/index.mjs";import{t as _}from"./schedule-C6tjcJ1O.mjs";import"./scope/index.mjs";import{t as v}from"./service-3PYQTUdH.mjs";export{e as Adt,r as Brand,i as Context,a as Data,s as Either,u as Fx,d as Layer,f as Multithread,o as Option,p as Order,m as Predicate,g as Provide,l as Queue,n as Result,_ as Schedule,h as Scope,v as Service,t as flow,c as pipe};
@@ -0,0 +1,2 @@
1
+ import { t as layer_d_exports } from "../index-7Lv982Om.mjs";
2
+ export { layer_d_exports as Layer };
@@ -0,0 +1 @@
1
+ import{t as e}from"../layer-BttmtDrs.mjs";export{e as Layer};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./chunk-C934ptG5.mjs";import{t}from"./fx.types-Bg-Mmdm5.mjs";import{i as n,n as r,r as i}from"./context-CCHj1nab.mjs";import{n as a,t as o}from"./service-resolution-C19smeaO.mjs";var s=e({err:()=>h,fx:()=>g,merge:()=>y,ok:()=>m,provide:()=>v,scoped:()=>_});const c=(e,n)=>({_tag:`Layer`,_ROut:void 0,_E:void 0,_RIn:void 0,_Sync:void 0,build:()=>({_tag:`SyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},*[Symbol.iterator](){return i(e,n)}})}),l=e=>({_tag:`Layer`,_ROut:void 0,_E:void 0,_RIn:void 0,_Sync:void 0,build:()=>({_tag:`SyncFx`,[t]:{_A:()=>void 0,_E:()=>e,_R:()=>void 0},*[Symbol.iterator](){throw yield e,Error(`Unreachable`)}})});function u(e){return n=>({_tag:`Layer`,_ROut:void 0,_E:void 0,_RIn:void 0,_Sync:void 0,build:()=>n._tag===`AsyncFx`?{_tag:`AsyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},async*[Symbol.asyncIterator](){let t=n[Symbol.asyncIterator](),r=await t.next();for(;r.done!==!0;){let e=yield r.value;r=await t.next(e)}return i(e,r.value)}}:{_tag:`SyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},*[Symbol.iterator](){let t=n[Symbol.iterator](),r=t.next();for(;r.done!==!0;){let e=yield r.value;r=t.next(e)}return i(e,r.value)}}})}function d(e){return n=>({_tag:`Layer`,_ROut:void 0,_E:void 0,_RIn:void 0,_Sync:void 0,build:(r,a)=>n._tag===`AsyncFx`?{_tag:`AsyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},async*[Symbol.asyncIterator](){let t=n[Symbol.asyncIterator](),r=await t.next();for(;r.done!==!0;){let e=r.value;if(o(e)?.key===`@std/Scope`)r=await t.next(a);else{let n=yield e;r=await t.next(n)}}return i(e,r.value)}}:{_tag:`SyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},*[Symbol.iterator](){let t=n[Symbol.iterator](),r=t.next();for(;r.done!==!0;){let e=r.value;if(o(e)?.key===`@std/Scope`)r=t.next(a);else{let n=yield e;r=t.next(n)}}return i(e,r.value)}}})}function f(e){return r=>({_tag:`Layer`,_ROut:void 0,_E:void 0,_RIn:void 0,_Sync:void 0,build:(i,o)=>{let s=e.build(i,o);return s._tag===`AsyncFx`?{_tag:`AsyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},async*[Symbol.asyncIterator](){let e=s[Symbol.asyncIterator](),t=await e.next();for(;t.done!==!0;){let n=yield t.value;t=await e.next(n)}let c=t.value,l=r.build(i,o);if(l._tag===`AsyncFx`){let e=l[Symbol.asyncIterator](),t=await e.next();for(;t.done!==!0;){let n=t.value,r=a(c,n);if(r!==void 0){t=await e.next(r);continue}let i=yield n;t=await e.next(i)}return n(c,t.value)}let u=l[Symbol.iterator](),d=u.next();for(;d.done!==!0;){let e=d.value,t=a(c,e);if(t!==void 0){d=u.next(t);continue}let n=yield e;d=u.next(n)}return n(c,d.value)}}:{_tag:`SyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},*[Symbol.iterator](){let e=s[Symbol.iterator](),t=e.next();for(;t.done!==!0;){let n=yield t.value;t=e.next(n)}let c=t.value,l=r.build(i,o);if(l._tag===`SyncFx`){let e=l[Symbol.iterator](),t=e.next();for(;t.done!==!0;){let n=t.value,r=a(c,n);if(r!==void 0){t=e.next(r);continue}let i=yield n;t=e.next(i)}return n(c,t.value)}throw Error(`Cannot use async layer in sync context`)}}}})}function p(...e){return{_tag:`Layer`,_ROut:void 0,_E:void 0,_RIn:void 0,_Sync:void 0,build:(i,o)=>e.some(e=>e.build(i,o)._tag===`AsyncFx`)?{_tag:`AsyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},async*[Symbol.asyncIterator](){let t=r();for(let r of e){let e=r.build(i,o);if(e._tag===`AsyncFx`){let r=e[Symbol.asyncIterator](),i=await r.next();for(;i.done!==!0;){let e=i.value,n=a(t,e);if(n!==void 0){i=await r.next(n);continue}let o=yield e;i=await r.next(o)}t=n(t,i.value)}else{let r=e[Symbol.iterator](),i=r.next();for(;i.done!==!0;){let e=i.value,n=a(t,e);if(n!==void 0){i=r.next(n);continue}let o=yield e;i=r.next(o)}t=n(t,i.value)}}return t}}:{_tag:`SyncFx`,[t]:{_A:()=>void 0,_E:()=>void 0,_R:()=>void 0},*[Symbol.iterator](){let t=r();for(let r of e){let e=r.build(i,o);if(e._tag!==`SyncFx`)throw Error(`Expected sync layer in sync context`);let s=e[Symbol.iterator](),c=s.next();for(;c.done!==!0;){let e=c.value,n=a(t,e);if(n!==void 0){c=s.next(n);continue}let r=yield e;c=s.next(r)}t=n(t,c.value)}return t}}}}const m=c,h=l,g=u,_=d,v=f,y=p;export{s as t};
2
+ //# sourceMappingURL=layer-BttmtDrs.mjs.map