@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.
- package/README.md +232 -33
- package/dist/adt/index.d.mts +2 -2
- package/dist/adt/index.mjs +1 -1
- package/dist/adt-DajUZvJe.mjs +2 -0
- package/dist/adt-DajUZvJe.mjs.map +1 -0
- package/dist/brand/index.d.mts +2 -2
- package/dist/brand/index.mjs +1 -1
- package/dist/brand-Bia3Vj6l.mjs +2 -0
- package/dist/brand-Bia3Vj6l.mjs.map +1 -0
- package/dist/context/index.d.mts +2 -0
- package/dist/context/index.mjs +1 -0
- package/dist/context-CCHj1nab.mjs +2 -0
- package/dist/context-CCHj1nab.mjs.map +1 -0
- package/dist/context-r8ESJiFn.d.mts +176 -0
- package/dist/context-r8ESJiFn.d.mts.map +1 -0
- package/dist/data/index.d.mts +2 -2
- package/dist/data/index.mjs +1 -1
- package/dist/data-BLXO4XwS.mjs +2 -0
- package/dist/data-BLXO4XwS.mjs.map +1 -0
- package/dist/data.tagged-error.types-CGiKD-ES.d.mts +29 -0
- package/dist/data.tagged-error.types-CGiKD-ES.d.mts.map +1 -0
- package/dist/{discriminator.types-9PxvrZki.d.mts → discriminator.types-CTURejXz.d.mts} +1 -1
- package/dist/discriminator.types-CTURejXz.d.mts.map +1 -0
- package/dist/dual-CZhzZslG.mjs +2 -0
- package/dist/dual-CZhzZslG.mjs.map +1 -0
- package/dist/either/index.d.mts +2 -2
- package/dist/either/index.mjs +1 -1
- package/dist/either-BMLPfvMl.mjs +2 -0
- package/dist/either-BMLPfvMl.mjs.map +1 -0
- package/dist/{equality-CD4_A1Op.mjs → equality-CoyUHWh9.mjs} +1 -1
- package/dist/{equality-CD4_A1Op.mjs.map → equality-CoyUHWh9.mjs.map} +1 -1
- package/dist/{flow-CYjiodlC.mjs → flow-D8_tllWl.mjs} +1 -1
- package/dist/flow-D8_tllWl.mjs.map +1 -0
- package/dist/functions/index.d.mts +2 -0
- package/dist/functions/index.mjs +1 -0
- package/dist/functions-BkevX2Dw.mjs +2 -0
- package/dist/functions-BkevX2Dw.mjs.map +1 -0
- package/dist/fx/index.d.mts +2 -3
- package/dist/fx/index.mjs +1 -1
- package/dist/fx-K-a9Smhn.mjs +2 -0
- package/dist/fx-K-a9Smhn.mjs.map +1 -0
- package/dist/fx.runtime-DclEDyjY.mjs +2 -0
- package/dist/fx.runtime-DclEDyjY.mjs.map +1 -0
- package/dist/{fx.types-CDVjDn_3.mjs → fx.types-Bg-Mmdm5.mjs} +1 -1
- package/dist/fx.types-Bg-Mmdm5.mjs.map +1 -0
- package/dist/{fx.types-B34asVRX.d.mts → fx.types-DeEWEltG.d.mts} +2 -2
- package/dist/{fx.types-B34asVRX.d.mts.map → fx.types-DeEWEltG.d.mts.map} +1 -1
- package/dist/index-7Lv982Om.d.mts +217 -0
- package/dist/index-7Lv982Om.d.mts.map +1 -0
- package/dist/{index-CklRfom5.d.mts → index-B1-tBzc0.d.mts} +263 -368
- package/dist/index-B1-tBzc0.d.mts.map +1 -0
- package/dist/index-BNQ9xSAz.d.mts +464 -0
- package/dist/index-BNQ9xSAz.d.mts.map +1 -0
- package/dist/index-B_iY5tq0.d.mts +241 -0
- package/dist/index-B_iY5tq0.d.mts.map +1 -0
- package/dist/index-B_wWGszy.d.mts +129 -0
- package/dist/index-B_wWGszy.d.mts.map +1 -0
- package/dist/index-BiiE8NS7.d.mts +108 -0
- package/dist/index-BiiE8NS7.d.mts.map +1 -0
- package/dist/index-By6dNRc4.d.mts +277 -0
- package/dist/index-By6dNRc4.d.mts.map +1 -0
- package/dist/{index-BzYtgdX0.d.mts → index-CGiLfREk.d.mts} +123 -16
- package/dist/index-CGiLfREk.d.mts.map +1 -0
- package/dist/index-CUZn-ohG.d.mts +490 -0
- package/dist/index-CUZn-ohG.d.mts.map +1 -0
- package/dist/index-Cq2IFito.d.mts +121 -0
- package/dist/index-Cq2IFito.d.mts.map +1 -0
- package/dist/{index-B2l8_CiD.d.mts → index-DEAWPlcI.d.mts} +155 -216
- package/dist/index-DEAWPlcI.d.mts.map +1 -0
- package/dist/{index-C4v_3f3-.d.mts → index-DKS1g1oC.d.mts} +95 -42
- package/dist/index-DKS1g1oC.d.mts.map +1 -0
- package/dist/{index-jeC5jyRh.d.mts → index-DXbYlSnB.d.mts} +64 -101
- package/dist/index-DXbYlSnB.d.mts.map +1 -0
- package/dist/{index-CjZ95Dsv.d.mts → index-UzMbg1dh.d.mts} +188 -202
- package/dist/index-UzMbg1dh.d.mts.map +1 -0
- package/dist/index.d.mts +23 -16
- package/dist/index.mjs +1 -1
- package/dist/layer/index.d.mts +2 -0
- package/dist/layer/index.mjs +1 -0
- package/dist/layer-BttmtDrs.mjs +2 -0
- package/dist/layer-BttmtDrs.mjs.map +1 -0
- package/dist/layer.types-DgpCIsk_.d.mts +100 -0
- package/dist/layer.types-DgpCIsk_.d.mts.map +1 -0
- package/dist/multithread/index.d.mts +2 -0
- package/dist/multithread/index.mjs +1 -0
- package/dist/multithread-xUUh4eLn.mjs +19 -0
- package/dist/multithread-xUUh4eLn.mjs.map +1 -0
- package/dist/option/index.d.mts +2 -3
- package/dist/option/index.mjs +1 -1
- package/dist/option-Tfbo4wty.mjs +2 -0
- package/dist/option-Tfbo4wty.mjs.map +1 -0
- package/dist/option.types-D1mm0zUb.mjs +2 -0
- package/dist/option.types-D1mm0zUb.mjs.map +1 -0
- package/dist/{option.types-ClJiBTdg.d.mts → option.types-qPevEZQd.d.mts} +7 -12
- package/dist/option.types-qPevEZQd.d.mts.map +1 -0
- package/dist/order/index.d.mts +2 -0
- package/dist/order/index.mjs +1 -0
- package/dist/order-D5c4QChk.mjs +2 -0
- package/dist/order-D5c4QChk.mjs.map +1 -0
- package/dist/pipeable-COGyGMUV.mjs +2 -0
- package/dist/pipeable-COGyGMUV.mjs.map +1 -0
- package/dist/{pipeable-B4YJA56p.d.mts → pipeable-rfqacPxZ.d.mts} +2 -9
- package/dist/{pipeable-B4YJA56p.d.mts.map → pipeable-rfqacPxZ.d.mts.map} +1 -1
- package/dist/predicate/index.d.mts +2 -2
- package/dist/predicate/index.mjs +1 -1
- package/dist/predicate-DUhhQqWY.mjs +2 -0
- package/dist/predicate-DUhhQqWY.mjs.map +1 -0
- package/dist/provide/index.d.mts +2 -0
- package/dist/provide/index.mjs +1 -0
- package/dist/provide-C2cWOx2B.mjs +2 -0
- package/dist/provide-C2cWOx2B.mjs.map +1 -0
- package/dist/queue/index.d.mts +2 -0
- package/dist/queue/index.mjs +1 -0
- package/dist/queue-Sg6KJerl.mjs +2 -0
- package/dist/queue-Sg6KJerl.mjs.map +1 -0
- package/dist/queue.types-CD2LOu37.d.mts +36 -0
- package/dist/queue.types-CD2LOu37.d.mts.map +1 -0
- package/dist/result/index.d.mts +2 -3
- package/dist/result/index.mjs +1 -1
- package/dist/result-BEzV0DYC.mjs +2 -0
- package/dist/result-BEzV0DYC.mjs.map +1 -0
- package/dist/{result.types-HHDzgSTV.d.mts → result.types-_xDAei3-.d.mts} +5 -97
- package/dist/result.types-_xDAei3-.d.mts.map +1 -0
- package/dist/schedule/index.d.mts +2 -0
- package/dist/schedule/index.mjs +1 -0
- package/dist/schedule-C6tjcJ1O.mjs +2 -0
- package/dist/schedule-C6tjcJ1O.mjs.map +1 -0
- package/dist/schedule-DlX2Dg69.d.mts +144 -0
- package/dist/schedule-DlX2Dg69.d.mts.map +1 -0
- package/dist/scope/index.d.mts +2 -0
- package/dist/scope/index.mjs +1 -0
- package/dist/scope-CZdp4wKX.d.mts +79 -0
- package/dist/scope-CZdp4wKX.d.mts.map +1 -0
- package/dist/scope-D_kzd1nT.mjs +2 -0
- package/dist/scope-D_kzd1nT.mjs.map +1 -0
- package/dist/service/index.d.mts +2 -0
- package/dist/service/index.mjs +1 -0
- package/dist/service-3PYQTUdH.mjs +2 -0
- package/dist/service-3PYQTUdH.mjs.map +1 -0
- package/dist/service-DrXU7KJG.d.mts +69 -0
- package/dist/service-DrXU7KJG.d.mts.map +1 -0
- package/dist/service-resolution-C19smeaO.mjs +2 -0
- package/dist/service-resolution-C19smeaO.mjs.map +1 -0
- package/package.json +50 -12
- package/dist/adt-CkRcY_GA.mjs +0 -2
- package/dist/adt-CkRcY_GA.mjs.map +0 -1
- package/dist/apply-fn.types-0g_9eXRy.d.mts +0 -8
- package/dist/apply-fn.types-0g_9eXRy.d.mts.map +0 -1
- package/dist/brand-Gy0kW6-n.mjs +0 -2
- package/dist/brand-Gy0kW6-n.mjs.map +0 -1
- package/dist/data-C0_3MGwm.mjs +0 -2
- package/dist/data-C0_3MGwm.mjs.map +0 -1
- package/dist/discriminator.types-9PxvrZki.d.mts.map +0 -1
- package/dist/either-CPzK-s8W.mjs +0 -2
- package/dist/either-CPzK-s8W.mjs.map +0 -1
- package/dist/err/index.d.mts +0 -2
- package/dist/err/index.mjs +0 -1
- package/dist/err-3KpQ4pj9.mjs +0 -2
- package/dist/err-3KpQ4pj9.mjs.map +0 -1
- package/dist/flow/index.d.mts +0 -2
- package/dist/flow/index.mjs +0 -1
- package/dist/flow-CYjiodlC.mjs.map +0 -1
- package/dist/fx-vqywVJhV.mjs +0 -2
- package/dist/fx-vqywVJhV.mjs.map +0 -1
- package/dist/fx.types-CDVjDn_3.mjs.map +0 -1
- package/dist/index-8Ne4GdOG.d.mts +0 -288
- package/dist/index-8Ne4GdOG.d.mts.map +0 -1
- package/dist/index-B2l8_CiD.d.mts.map +0 -1
- package/dist/index-BOrJQBPO.d.mts +0 -80
- package/dist/index-BOrJQBPO.d.mts.map +0 -1
- package/dist/index-BsXtpnw-.d.mts +0 -225
- package/dist/index-BsXtpnw-.d.mts.map +0 -1
- package/dist/index-BzYtgdX0.d.mts.map +0 -1
- package/dist/index-C4v_3f3-.d.mts.map +0 -1
- package/dist/index-CjZ95Dsv.d.mts.map +0 -1
- package/dist/index-CklRfom5.d.mts.map +0 -1
- package/dist/index-DZdmFtjA.d.mts +0 -79
- package/dist/index-DZdmFtjA.d.mts.map +0 -1
- package/dist/index-a4MEBZZ1.d.mts +0 -850
- package/dist/index-a4MEBZZ1.d.mts.map +0 -1
- package/dist/index-jeC5jyRh.d.mts.map +0 -1
- package/dist/option-DawZC1cE.mjs +0 -2
- package/dist/option-DawZC1cE.mjs.map +0 -1
- package/dist/option.types-ClJiBTdg.d.mts.map +0 -1
- package/dist/pipe/index.d.mts +0 -2
- package/dist/pipe/index.mjs +0 -1
- package/dist/pipe-BPpJyZf7.mjs +0 -2
- package/dist/pipe-BPpJyZf7.mjs.map +0 -1
- package/dist/pipeable-BA0mXhs4.mjs +0 -2
- package/dist/pipeable-BA0mXhs4.mjs.map +0 -1
- package/dist/predicate-Cy_oHA1Q.mjs +0 -2
- package/dist/predicate-Cy_oHA1Q.mjs.map +0 -1
- package/dist/result-CgGYLp0L.mjs +0 -2
- package/dist/result-CgGYLp0L.mjs.map +0 -1
- package/dist/result.types-HHDzgSTV.d.mts.map +0 -1
- /package/dist/{chunk-DAexk1S7.mjs → chunk-C934ptG5.mjs} +0 -0
- /package/dist/{option-Bb-taghv.mjs → option-CBCwzF0L.mjs} +0 -0
- /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-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
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
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* //
|
|
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
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
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
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* //
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
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
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
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
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
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
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
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
|
-
*
|
|
283
|
-
*
|
|
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
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
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
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
375
|
-
*
|
|
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
|
-
* @
|
|
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
|
|
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-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { t as
|
|
11
|
-
import {
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { t as
|
|
16
|
-
|
|
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-
|
|
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 @@
|
|
|
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
|