@nicolastoulemont/std 0.7.1 → 0.8.0

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 (210) hide show
  1. package/README.md +570 -168
  2. package/dist/adt/index.d.mts +1 -1
  3. package/dist/adt/index.mjs +1 -1
  4. package/dist/adt-CzdkjlUM.mjs +2 -0
  5. package/dist/adt-CzdkjlUM.mjs.map +1 -0
  6. package/dist/brand/index.d.mts +1 -1
  7. package/dist/brand/index.mjs +1 -1
  8. package/dist/brand-DZgGDrAe.mjs +2 -0
  9. package/dist/brand-DZgGDrAe.mjs.map +1 -0
  10. package/dist/brand.types-B3NDX1vo.d.mts +62 -0
  11. package/dist/brand.types-B3NDX1vo.d.mts.map +1 -0
  12. package/dist/context/index.d.mts +1 -1
  13. package/dist/context/index.mjs +1 -1
  14. package/dist/{context-CCHj1nab.mjs → context-0xDbwtpx.mjs} +2 -2
  15. package/dist/context-0xDbwtpx.mjs.map +1 -0
  16. package/dist/{context-r8ESJiFn.d.mts → context-B2dWloPl.d.mts} +2 -18
  17. package/dist/context-B2dWloPl.d.mts.map +1 -0
  18. package/dist/data/index.d.mts +1 -1
  19. package/dist/data/index.mjs +1 -1
  20. package/dist/{data-BLXO4XwS.mjs → data-BHYPdqWZ.mjs} +2 -2
  21. package/dist/{data-BLXO4XwS.mjs.map → data-BHYPdqWZ.mjs.map} +1 -1
  22. package/dist/{discriminator.types-CTURejXz.d.mts → discriminator.types-C-ygT2S1.d.mts} +1 -1
  23. package/dist/discriminator.types-C-ygT2S1.d.mts.map +1 -0
  24. package/dist/{dual-CZhzZslG.mjs → dual-fN6OUwN_.mjs} +1 -1
  25. package/dist/{dual-CZhzZslG.mjs.map → dual-fN6OUwN_.mjs.map} +1 -1
  26. package/dist/duration/index.d.mts +2 -0
  27. package/dist/duration/index.mjs +1 -0
  28. package/dist/duration-CYoDHcOR.mjs +2 -0
  29. package/dist/duration-CYoDHcOR.mjs.map +1 -0
  30. package/dist/either/index.d.mts +1 -1
  31. package/dist/either/index.mjs +1 -1
  32. package/dist/{either-BMLPfvMl.mjs → either-G7uOu4Ar.mjs} +2 -2
  33. package/dist/either-G7uOu4Ar.mjs.map +1 -0
  34. package/dist/{equality-CoyUHWh9.mjs → equality-BX6BUidG.mjs} +1 -1
  35. package/dist/{equality-CoyUHWh9.mjs.map → equality-BX6BUidG.mjs.map} +1 -1
  36. package/dist/{flow-D8_tllWl.mjs → flow-CNyLsPGb.mjs} +1 -1
  37. package/dist/flow-CNyLsPGb.mjs.map +1 -0
  38. package/dist/functions/index.d.mts +1 -1
  39. package/dist/functions/index.mjs +1 -1
  40. package/dist/functions-ByAk682_.mjs +2 -0
  41. package/dist/functions-ByAk682_.mjs.map +1 -0
  42. package/dist/fx/index.d.mts +1 -1
  43. package/dist/fx/index.mjs +1 -1
  44. package/dist/fx-DUXDxwsU.mjs +2 -0
  45. package/dist/fx-DUXDxwsU.mjs.map +1 -0
  46. package/dist/{fx.runtime-DclEDyjY.mjs → fx.runtime-jQxh77s3.mjs} +2 -2
  47. package/dist/{fx.runtime-DclEDyjY.mjs.map → fx.runtime-jQxh77s3.mjs.map} +1 -1
  48. package/dist/{fx.types-DeEWEltG.d.mts → fx.types-BdN1EWxr.d.mts} +1 -1
  49. package/dist/{fx.types-DeEWEltG.d.mts.map → fx.types-BdN1EWxr.d.mts.map} +1 -1
  50. package/dist/{fx.types-Bg-Mmdm5.mjs → fx.types-DyQVgTS8.mjs} +1 -1
  51. package/dist/{fx.types-Bg-Mmdm5.mjs.map → fx.types-DyQVgTS8.mjs.map} +1 -1
  52. package/dist/{index-DXbYlSnB.d.mts → index-BA0EsFxS.d.mts} +5 -74
  53. package/dist/index-BA0EsFxS.d.mts.map +1 -0
  54. package/dist/{index-UzMbg1dh.d.mts → index-BqJ1GWAF.d.mts} +20 -56
  55. package/dist/index-BqJ1GWAF.d.mts.map +1 -0
  56. package/dist/index-BsPOcZk9.d.mts +96 -0
  57. package/dist/index-BsPOcZk9.d.mts.map +1 -0
  58. package/dist/{index-DEAWPlcI.d.mts → index-CIvNgjsx.d.mts} +24 -56
  59. package/dist/index-CIvNgjsx.d.mts.map +1 -0
  60. package/dist/{index-B_iY5tq0.d.mts → index-CNTYbcY9.d.mts} +1 -21
  61. package/dist/index-CNTYbcY9.d.mts.map +1 -0
  62. package/dist/index-Ctg7XUOs.d.mts +36 -0
  63. package/dist/index-Ctg7XUOs.d.mts.map +1 -0
  64. package/dist/{index-Cq2IFito.d.mts → index-Ctqe1fD1.d.mts} +3 -17
  65. package/dist/index-Ctqe1fD1.d.mts.map +1 -0
  66. package/dist/{index-B_wWGszy.d.mts → index-D7mFNjot.d.mts} +1 -5
  67. package/dist/index-D7mFNjot.d.mts.map +1 -0
  68. package/dist/{index-CUZn-ohG.d.mts → index-D8rDE60Y.d.mts} +23 -54
  69. package/dist/index-D8rDE60Y.d.mts.map +1 -0
  70. package/dist/{index-By6dNRc4.d.mts → index-DR7hzXU4.d.mts} +3 -23
  71. package/dist/{index-By6dNRc4.d.mts.map → index-DR7hzXU4.d.mts.map} +1 -1
  72. package/dist/{index-DKS1g1oC.d.mts → index-DfQGXBQI.d.mts} +54 -45
  73. package/dist/index-DfQGXBQI.d.mts.map +1 -0
  74. package/dist/{index-BNQ9xSAz.d.mts → index-MsJqfQu0.d.mts} +64 -70
  75. package/dist/index-MsJqfQu0.d.mts.map +1 -0
  76. package/dist/{index-CGiLfREk.d.mts → index-UINIHFuh.d.mts} +39 -15
  77. package/dist/index-UINIHFuh.d.mts.map +1 -0
  78. package/dist/{index-BiiE8NS7.d.mts → index-crtzMG48.d.mts} +14 -23
  79. package/dist/index-crtzMG48.d.mts.map +1 -0
  80. package/dist/{index-B1-tBzc0.d.mts → index-dCRymj_g.d.mts} +23 -71
  81. package/dist/{index-B1-tBzc0.d.mts.map → index-dCRymj_g.d.mts.map} +1 -1
  82. package/dist/index-uE3S3Krx.d.mts +245 -0
  83. package/dist/index-uE3S3Krx.d.mts.map +1 -0
  84. package/dist/index.d.mts +21 -19
  85. package/dist/index.mjs +1 -1
  86. package/dist/layer/index.d.mts +1 -1
  87. package/dist/layer/index.mjs +1 -1
  88. package/dist/{layer-BttmtDrs.mjs → layer-CKtH7TRL.mjs} +2 -2
  89. package/dist/layer-CKtH7TRL.mjs.map +1 -0
  90. package/dist/{layer.types-DgpCIsk_.d.mts → layer.types-BB0MrvLg.d.mts} +4 -4
  91. package/dist/{layer.types-DgpCIsk_.d.mts.map → layer.types-BB0MrvLg.d.mts.map} +1 -1
  92. package/dist/multithread/index.d.mts +1 -1
  93. package/dist/multithread/index.mjs +1 -1
  94. package/dist/{multithread-xUUh4eLn.mjs → multithread-Cyc8Bz45.mjs} +2 -2
  95. package/dist/multithread-Cyc8Bz45.mjs.map +1 -0
  96. package/dist/option/index.d.mts +1 -1
  97. package/dist/option/index.mjs +1 -1
  98. package/dist/{option-Tfbo4wty.mjs → option-C2iCxAuJ.mjs} +2 -2
  99. package/dist/option-C2iCxAuJ.mjs.map +1 -0
  100. package/dist/{option.types-D1mm0zUb.mjs → option.types-CbY_swma.mjs} +1 -1
  101. package/dist/{option.types-D1mm0zUb.mjs.map → option.types-CbY_swma.mjs.map} +1 -1
  102. package/dist/{option.types-qPevEZQd.d.mts → option.types-D9hrKcfa.d.mts} +3 -3
  103. package/dist/{option.types-qPevEZQd.d.mts.map → option.types-D9hrKcfa.d.mts.map} +1 -1
  104. package/dist/order/index.d.mts +1 -1
  105. package/dist/order/index.mjs +1 -1
  106. package/dist/order-BXOBEKvB.mjs +2 -0
  107. package/dist/order-BXOBEKvB.mjs.map +1 -0
  108. package/dist/{pipeable-rfqacPxZ.d.mts → pipeable-BIrevC0D.d.mts} +1 -1
  109. package/dist/{pipeable-rfqacPxZ.d.mts.map → pipeable-BIrevC0D.d.mts.map} +1 -1
  110. package/dist/pipeable-Dp1_23zH.mjs +2 -0
  111. package/dist/{pipeable-COGyGMUV.mjs.map → pipeable-Dp1_23zH.mjs.map} +1 -1
  112. package/dist/predicate/index.d.mts +1 -1
  113. package/dist/predicate/index.mjs +1 -1
  114. package/dist/{predicate-DUhhQqWY.mjs → predicate-D_1SsIi4.mjs} +2 -2
  115. package/dist/predicate-D_1SsIi4.mjs.map +1 -0
  116. package/dist/provide/index.d.mts +1 -1
  117. package/dist/provide/index.mjs +1 -1
  118. package/dist/provide--yZE8x-n.mjs +2 -0
  119. package/dist/provide--yZE8x-n.mjs.map +1 -0
  120. package/dist/queue/index.d.mts +1 -1
  121. package/dist/queue/index.mjs +1 -1
  122. package/dist/{queue-Sg6KJerl.mjs → queue-apiEOlRD.mjs} +2 -2
  123. package/dist/queue-apiEOlRD.mjs.map +1 -0
  124. package/dist/{queue.types-CD2LOu37.d.mts → queue.types-B-l5XYbU.d.mts} +1 -1
  125. package/dist/{queue.types-CD2LOu37.d.mts.map → queue.types-B-l5XYbU.d.mts.map} +1 -1
  126. package/dist/result/index.d.mts +1 -1
  127. package/dist/result/index.mjs +1 -1
  128. package/dist/{result-BEzV0DYC.mjs → result-D3VY0qBG.mjs} +2 -2
  129. package/dist/result-D3VY0qBG.mjs.map +1 -0
  130. package/dist/{result.types-_xDAei3-.d.mts → result.types-BKzChyWY.d.mts} +3 -3
  131. package/dist/{result.types-_xDAei3-.d.mts.map → result.types-BKzChyWY.d.mts.map} +1 -1
  132. package/dist/schedule/index.d.mts +1 -1
  133. package/dist/schedule/index.mjs +1 -1
  134. package/dist/schedule-B9K_2Z21.d.mts +183 -0
  135. package/dist/schedule-B9K_2Z21.d.mts.map +1 -0
  136. package/dist/schedule-C6iN3oMt.mjs +2 -0
  137. package/dist/schedule-C6iN3oMt.mjs.map +1 -0
  138. package/dist/schema/index.d.mts +2 -0
  139. package/dist/schema/index.mjs +1 -0
  140. package/dist/schema-D87TVF_b.mjs +2 -0
  141. package/dist/schema-D87TVF_b.mjs.map +1 -0
  142. package/dist/schema.shared-CI4eydjX.mjs +2 -0
  143. package/dist/schema.shared-CI4eydjX.mjs.map +1 -0
  144. package/dist/schema.types-CFzzx4bw.d.mts +45 -0
  145. package/dist/schema.types-CFzzx4bw.d.mts.map +1 -0
  146. package/dist/scope/index.d.mts +1 -1
  147. package/dist/scope/index.mjs +1 -1
  148. package/dist/{scope-CZdp4wKX.d.mts → scope-CuM3CzwG.d.mts} +3 -9
  149. package/dist/scope-CuM3CzwG.d.mts.map +1 -0
  150. package/dist/{scope-D_kzd1nT.mjs → scope-gVt4PESc.mjs} +2 -2
  151. package/dist/scope-gVt4PESc.mjs.map +1 -0
  152. package/dist/service/index.d.mts +1 -1
  153. package/dist/service/index.mjs +1 -1
  154. package/dist/{service-3PYQTUdH.mjs → service-CWAIEH46.mjs} +2 -2
  155. package/dist/service-CWAIEH46.mjs.map +1 -0
  156. package/dist/{service-DrXU7KJG.d.mts → service-D8mr0wwg.d.mts} +2 -8
  157. package/dist/service-D8mr0wwg.d.mts.map +1 -0
  158. package/dist/{service-resolution-C19smeaO.mjs → service-resolution-BefYr4nR.mjs} +1 -1
  159. package/dist/{service-resolution-C19smeaO.mjs.map → service-resolution-BefYr4nR.mjs.map} +1 -1
  160. package/package.json +9 -1
  161. package/dist/adt-DajUZvJe.mjs +0 -2
  162. package/dist/adt-DajUZvJe.mjs.map +0 -1
  163. package/dist/brand-Bia3Vj6l.mjs +0 -2
  164. package/dist/brand-Bia3Vj6l.mjs.map +0 -1
  165. package/dist/context-CCHj1nab.mjs.map +0 -1
  166. package/dist/context-r8ESJiFn.d.mts.map +0 -1
  167. package/dist/data.tagged-error.types-CGiKD-ES.d.mts +0 -29
  168. package/dist/data.tagged-error.types-CGiKD-ES.d.mts.map +0 -1
  169. package/dist/discriminator.types-CTURejXz.d.mts.map +0 -1
  170. package/dist/either-BMLPfvMl.mjs.map +0 -1
  171. package/dist/flow-D8_tllWl.mjs.map +0 -1
  172. package/dist/functions-BkevX2Dw.mjs +0 -2
  173. package/dist/functions-BkevX2Dw.mjs.map +0 -1
  174. package/dist/fx-K-a9Smhn.mjs +0 -2
  175. package/dist/fx-K-a9Smhn.mjs.map +0 -1
  176. package/dist/index-7Lv982Om.d.mts +0 -217
  177. package/dist/index-7Lv982Om.d.mts.map +0 -1
  178. package/dist/index-BNQ9xSAz.d.mts.map +0 -1
  179. package/dist/index-B_iY5tq0.d.mts.map +0 -1
  180. package/dist/index-B_wWGszy.d.mts.map +0 -1
  181. package/dist/index-BiiE8NS7.d.mts.map +0 -1
  182. package/dist/index-CGiLfREk.d.mts.map +0 -1
  183. package/dist/index-CUZn-ohG.d.mts.map +0 -1
  184. package/dist/index-Cq2IFito.d.mts.map +0 -1
  185. package/dist/index-DEAWPlcI.d.mts.map +0 -1
  186. package/dist/index-DKS1g1oC.d.mts.map +0 -1
  187. package/dist/index-DXbYlSnB.d.mts.map +0 -1
  188. package/dist/index-UzMbg1dh.d.mts.map +0 -1
  189. package/dist/layer-BttmtDrs.mjs.map +0 -1
  190. package/dist/multithread-xUUh4eLn.mjs.map +0 -1
  191. package/dist/option-Tfbo4wty.mjs.map +0 -1
  192. package/dist/order-D5c4QChk.mjs +0 -2
  193. package/dist/order-D5c4QChk.mjs.map +0 -1
  194. package/dist/pipeable-COGyGMUV.mjs +0 -2
  195. package/dist/predicate-DUhhQqWY.mjs.map +0 -1
  196. package/dist/provide-C2cWOx2B.mjs +0 -2
  197. package/dist/provide-C2cWOx2B.mjs.map +0 -1
  198. package/dist/queue-Sg6KJerl.mjs.map +0 -1
  199. package/dist/result-BEzV0DYC.mjs.map +0 -1
  200. package/dist/schedule-C6tjcJ1O.mjs +0 -2
  201. package/dist/schedule-C6tjcJ1O.mjs.map +0 -1
  202. package/dist/schedule-DlX2Dg69.d.mts +0 -144
  203. package/dist/schedule-DlX2Dg69.d.mts.map +0 -1
  204. package/dist/scope-CZdp4wKX.d.mts.map +0 -1
  205. package/dist/scope-D_kzd1nT.mjs.map +0 -1
  206. package/dist/service-3PYQTUdH.mjs.map +0 -1
  207. package/dist/service-DrXU7KJG.d.mts.map +0 -1
  208. /package/dist/{chunk-C934ptG5.mjs → chunk-oQKkju2G.mjs} +0 -0
  209. /package/dist/{option-CBCwzF0L.mjs → option-CXXiA1w-.mjs} +0 -0
  210. /package/dist/{result-B5WbPg8C.mjs → result-xFLfwriM.mjs} +0 -0
@@ -1,64 +1,7 @@
1
- import { t as Result } from "./result.types-_xDAei3-.mjs";
1
+ import { t as Result } from "./result.types-BKzChyWY.mjs";
2
+ import { i as Validator, n as Branded$1, r as Unbrand, t as BrandError$1 } from "./brand.types-B3NDX1vo.mjs";
2
3
 
3
- //#region src/brand/brand.types.d.ts
4
- /**
5
- * Unique symbol for brand keys to ensure true nominal typing.
6
- * Using a symbol prevents collision with actual property keys.
7
- */
8
- declare const BrandSymbol: unique symbol;
9
- /**
10
- * A brand type that adds nominal typing to TypeScript.
11
- * The brand exists only at the type level - no runtime cost.
12
- *
13
- * @template K - The brand key (typically a string literal type)
14
- */
15
- type Brand<K extends string> = {
16
- readonly [BrandSymbol]: K;
17
- };
18
- /**
19
- * Create a branded type by intersecting a base type with a brand.
20
- * The resulting type is structurally compatible with T but nominally unique.
21
- *
22
- * @template T - The base type to brand
23
- * @template K - The brand key (string literal)
24
- *
25
- * @example
26
- * ```ts
27
- * type UserId = Branded<string, "UserId">
28
- * type OrderId = Branded<string, "OrderId">
29
- *
30
- * // UserId and OrderId are incompatible even though both are strings
31
- * declare const userId: UserId
32
- * declare const orderId: OrderId
33
- * userId = orderId // Type error!
34
- * ```
35
- */
36
- type Branded$1<T, K extends string> = T & Brand<K>;
37
- /**
38
- * Extract the base type from a branded type.
39
- * Useful for working with the underlying value.
40
- *
41
- * @template B - A branded type
42
- */
43
- type Unbrand<B> = B extends Branded$1<infer T, string> ? T : B;
44
- /**
45
- * A validation function that checks if a value can be branded.
46
- * Returns true if the value passes validation, false otherwise.
47
- *
48
- * @template T - The base type being validated
49
- */
50
- type Validator<T> = (value: T) => boolean;
51
- /**
52
- * Error type returned when brand validation fails.
53
- * Contains the original value and error message for debugging.
54
- *
55
- * @template T - The type of the value that failed validation
56
- */
57
- type BrandError$1<T = unknown> = {
58
- readonly _tag: "BrandError";
59
- readonly value: T;
60
- readonly message: string;
61
- };
4
+ //#region src/brand/brand.d.ts
62
5
  declare namespace brand_d_exports {
63
6
  export { BrandError, Branded, is, make, refine, unsafeMake };
64
7
  }
@@ -71,8 +14,6 @@ declare namespace brand_d_exports {
71
14
  *
72
15
  * type Example = typeof Brand
73
16
  * ```
74
- *
75
- * @category Type-level
76
17
  */
77
18
  type Branded<T, K extends string> = Branded$1<T, K>;
78
19
  /**
@@ -84,8 +25,6 @@ type Branded<T, K extends string> = Branded$1<T, K>;
84
25
  *
85
26
  * type Example = typeof Brand
86
27
  * ```
87
- *
88
- * @category Type-level
89
28
  */
90
29
  type BrandError<T> = BrandError$1<T>;
91
30
  /**
@@ -108,8 +47,6 @@ type BrandError<T> = BrandError$1<T>;
108
47
  * const userId = Brand.make<UserId>(raw)
109
48
  * // => brand-preserving cast
110
49
  * ```
111
- *
112
- * @category Utilities
113
50
  */
114
51
  declare const make: <B extends Branded<unknown, string>>(value: Unbrand<B>) => B;
115
52
  /**
@@ -129,8 +66,6 @@ declare const make: <B extends Branded<unknown, string>>(value: Unbrand<B>) => B
129
66
  * const userId = Brand.unsafeMake<UserId>(raw)
130
67
  * // => unchecked brand cast
131
68
  * ```
132
- *
133
- * @category Utilities
134
69
  */
135
70
  declare const unsafeMake: <B extends Branded<unknown, string>>(value: Unbrand<B>) => B;
136
71
  /**
@@ -151,8 +86,6 @@ declare const unsafeMake: <B extends Branded<unknown, string>>(value: Unbrand<B>
151
86
  * const valid = isUserId("user_123")
152
87
  * // => true
153
88
  * ```
154
- *
155
- * @category Utilities
156
89
  */
157
90
  declare const is: <T, K extends string>(validator: Validator<T>) => ((value: T) => value is Branded<T, K>);
158
91
  /**
@@ -172,13 +105,11 @@ declare const is: <T, K extends string>(validator: Validator<T>) => ((value: T)
172
105
  *
173
106
  * type UserId = Brand.Branded<string, "UserId">
174
107
  * const toUserId = Brand.refine<UserId>((value) => value.startsWith("user_"), "Invalid user id")
175
- * const parsed = toUserId("user_123" as UserId)
108
+ * const parsed = toUserId("user_123")
176
109
  * // => { _tag: "Ok", value: "user_123" }
177
110
  * ```
178
- *
179
- * @category Utilities
180
111
  */
181
112
  declare const refine: <B extends Branded<unknown, string>>(validator: Validator<Unbrand<B>>, errorMessage?: string | ((value: Unbrand<B>) => string)) => ((value: Unbrand<B>) => Result<B, BrandError<Unbrand<B>>>);
182
113
  //#endregion
183
114
  export { brand_d_exports as t };
184
- //# sourceMappingURL=index-DXbYlSnB.d.mts.map
115
+ //# sourceMappingURL=index-BA0EsFxS.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BA0EsFxS.d.mts","names":[],"sources":["../src/brand/brand.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;KA4CY,+BAA+B,UAAY,GAAG;AAA1D;;;;;AAYA;AAyBA;;;;AAA6E,KAzBjE,UAyBiE,CAAA,CAAA,CAAA,GAzBjD,YAyBiD,CAzBlC,CAyBkC,CAAA;;AAsB7E;;;;;;AAuBA;;;;;;;;AAyBA;;;;;;AAEmC,cAxEtB,IAwEsB,EAAA,CAAA,UAxEJ,OAwEI,CAAA,OAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,EAxE6B,OAwE7B,CAxEqC,CAwErC,CAAA,EAAA,GAxE0C,CAwE1C;;;;;;;;;;;;;;;;;;;cAlDtB,uBAAwB,iCAAiC,QAAQ,OAAK;;;;;;;;;;;;;;;;;;;;cAuBtE,qCAAsC,UAAU,gBAAc,eAAe,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;cAyBxF,mBAAoB,qCACpB,UAAU,QAAQ,sCACI,QAAQ,4BAC/B,QAAQ,OAAO,OAAW,GAAG,WAAW,QAAQ"}
@@ -1,4 +1,4 @@
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";
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-D9hrKcfa.mjs";
2
2
 
3
3
  //#region src/option/option.d.ts
4
4
  declare namespace option_d_exports {
@@ -14,8 +14,6 @@ declare namespace option_d_exports {
14
14
  * const error = new Option.NoSuchElementError()
15
15
  * // => error.name === "NoSuchElementError"
16
16
  * ```
17
- *
18
- * @category Re-exports
19
17
  */
20
18
  declare const NoSuchElementError: typeof NoSuchElementError$1;
21
19
  /**
@@ -27,8 +25,6 @@ declare const NoSuchElementError: typeof NoSuchElementError$1;
27
25
  *
28
26
  * type Example = Option.NoSuchElementError
29
27
  * ```
30
- *
31
- * @category Re-exports
32
28
  */
33
29
  type NoSuchElementError = InstanceType<typeof NoSuchElementError$1>;
34
30
  /**
@@ -40,8 +36,6 @@ type NoSuchElementError = InstanceType<typeof NoSuchElementError$1>;
40
36
  *
41
37
  * type Example = Option.Option<unknown>
42
38
  * ```
43
- *
44
- * @category Re-exports
45
39
  */
46
40
  type Option<T> = Option$1<T>;
47
41
  /**
@@ -57,8 +51,6 @@ type Option<T> = Option$1<T>;
57
51
  * const value = Option.some(42)
58
52
  * // => { _tag: "Some", value: 42 }
59
53
  * ```
60
- *
61
- * @category Constructors
62
54
  */
63
55
  declare const some: <T>(value: T) => Option$1<T>;
64
56
  /**
@@ -73,8 +65,6 @@ declare const some: <T>(value: T) => Option$1<T>;
73
65
  * const value = Option.none<number>()
74
66
  * // => { _tag: "None" }
75
67
  * ```
76
- *
77
- * @category Constructors
78
68
  */
79
69
  declare const none: <T = never>() => Option$1<T>;
80
70
  /**
@@ -90,8 +80,6 @@ declare const none: <T = never>() => Option$1<T>;
90
80
  * const value = Option.isSome(Option.some(1))
91
81
  * // => true
92
82
  * ```
93
- *
94
- * @category Guards
95
83
  */
96
84
  declare const isSome: <T>(option: Option$1<T>) => option is Extract<Option$1<T>, {
97
85
  _tag: "Some";
@@ -106,8 +94,6 @@ declare const isSome: <T>(option: Option$1<T>) => option is Extract<Option$1<T>,
106
94
  * const value = Option.isNone(Option.none())
107
95
  * // => true
108
96
  * ```
109
- *
110
- * @category Guards
111
97
  */
112
98
  declare const isNone: <T>(option: Option$1<T>) => option is Extract<Option$1<T>, {
113
99
  _tag: "None";
@@ -120,12 +106,12 @@ declare const isNone: <T>(option: Option$1<T>) => option is Extract<Option$1<T>,
120
106
  * - Data-first: `map(option, fn)`
121
107
  * - Data-last: `pipe(option, map(fn))`
122
108
  *
123
- * Supports both sync and async functions:
124
- * - Sync fn: returns Option<U>
125
- * - Async fn: returns Promise<Option<U>>
109
+ * Supports both sync and async callbacks:
110
+ * - Sync fn: returns U
111
+ * - Async fn: returns Promise<U>
126
112
  *
127
- * @param fn - Function to transform the value
128
- * @returns A function that takes an Option and returns a new Option
113
+ * @param fn - Function that transforms the contained value
114
+ * @returns The mapped Option in data-first form, or a function that maps an Option in data-last form
129
115
  *
130
116
  * @example
131
117
  * ```ts
@@ -138,8 +124,6 @@ declare const isNone: <T>(option: Option$1<T>) => option is Extract<Option$1<T>,
138
124
  * const dataLast = Option.map((n: number) => n + 1)(input)
139
125
  * // => { _tag: "Some", value: 3 }
140
126
  * ```
141
- *
142
- * @category Mapping
143
127
  */
144
128
  declare const map: OptionMap;
145
129
  /**
@@ -155,7 +139,7 @@ declare const map: OptionMap;
155
139
  * - Async fn: returns Promise<Option<U>>
156
140
  *
157
141
  * @param fn - Function that takes a value and returns an Option (or Promise<Option>)
158
- * @returns A function that takes an Option and returns a new Option
142
+ * @returns The resulting Option in data-first form, or a function that flatMaps an Option in data-last form
159
143
  *
160
144
  * @example
161
145
  * ```ts
@@ -168,8 +152,6 @@ declare const map: OptionMap;
168
152
  * const dataLast = Option.flatMap((n: number) => Option.some(n + 1))(input)
169
153
  * // => { _tag: "Some", value: 3 }
170
154
  * ```
171
- *
172
- * @category Sequencing
173
155
  */
174
156
  declare const flatMap: OptionFlatMap;
175
157
  /**
@@ -181,12 +163,12 @@ declare const flatMap: OptionFlatMap;
181
163
  * - Data-first: `tap(option, fn)`
182
164
  * - Data-last: `pipe(option, tap(fn))`
183
165
  *
184
- * Supports both sync and async functions:
185
- * - Sync fn: returns Option<T>
186
- * - Async fn: returns Promise<Option<T>>
166
+ * Supports both sync and async side effects:
167
+ * - Sync fn: returns any value (ignored)
168
+ * - Async fn: returns Promise<unknown>
187
169
  *
188
170
  * @param fn - Function to call with the value (return value is ignored)
189
- * @returns A function that takes an Option and returns the same Option
171
+ * @returns The original Option in data-first form, or a function that taps an Option in data-last form
190
172
  *
191
173
  * @example
192
174
  * ```ts
@@ -204,8 +186,6 @@ declare const flatMap: OptionFlatMap;
204
186
  * })(input)
205
187
  * // => { _tag: "Some", value: 2 }
206
188
  * ```
207
- *
208
- * @category Sequencing
209
189
  */
210
190
  declare const tap: OptionTap;
211
191
  /**
@@ -216,12 +196,12 @@ declare const tap: OptionTap;
216
196
  * - Data-first: `orElse(option, fn)`
217
197
  * - Data-last: `pipe(option, orElse(fn))`
218
198
  *
219
- * Supports both sync and async functions:
220
- * - Sync fn: returns Option<T | U>
221
- * - Async fn: returns Promise<Option<T | U>>
199
+ * Supports both sync and async fallback functions:
200
+ * - Sync fn: returns Option<U>
201
+ * - Async fn: returns Promise<Option<U>>
222
202
  *
223
203
  * @param fn - Function that returns an alternative Option
224
- * @returns A function that takes an Option and returns a new Option
204
+ * @returns The original or fallback Option in data-first form, or a function that recovers from none in data-last form
225
205
  *
226
206
  * @example
227
207
  * ```ts
@@ -234,8 +214,6 @@ declare const tap: OptionTap;
234
214
  * const dataLast = Option.orElse(() => Option.some(0))(input)
235
215
  * // => { _tag: "Some", value: 0 }
236
216
  * ```
237
- *
238
- * @category Combining
239
217
  */
240
218
  declare const orElse: OptionOrElse;
241
219
  /**
@@ -248,7 +226,7 @@ declare const orElse: OptionOrElse;
248
226
  * - Data-last: `pipe(option, filter(predicate))`
249
227
  *
250
228
  * @param predicate - Function that returns true to keep the value
251
- * @returns A function that takes an Option and returns a new Option
229
+ * @returns The filtered Option in data-first form, or a function that filters an Option in data-last form
252
230
  *
253
231
  * @example
254
232
  * ```ts
@@ -261,8 +239,6 @@ declare const orElse: OptionOrElse;
261
239
  * const dataLast = Option.filter((n: number) => n > 0)(input)
262
240
  * // => { _tag: "Some", value: 3 }
263
241
  * ```
264
- *
265
- * @category Filtering
266
242
  */
267
243
  declare const filter: OptionFilter;
268
244
  /**
@@ -282,8 +258,6 @@ declare const filter: OptionFilter;
282
258
  * const combined = Option.all([Option.some(1), Option.some(2)] as const)
283
259
  * // => { _tag: "Some", value: [1, 2] }
284
260
  * ```
285
- *
286
- * @category Combining
287
261
  */
288
262
  declare const all: OptionAll;
289
263
  /**
@@ -296,7 +270,7 @@ declare const all: OptionAll;
296
270
  * Uses NoInfer to prevent type inference from the default value.
297
271
  *
298
272
  * @param defaultValue - Value to return if the Option is none
299
- * @returns A function that takes an Option and returns the value or default
273
+ * @returns The unwrapped value in data-first form, or a function that unwraps an Option with a default in data-last form
300
274
  *
301
275
  * @example
302
276
  * ```ts
@@ -309,8 +283,6 @@ declare const all: OptionAll;
309
283
  * const dataLast = Option.unwrapOr(0)(input)
310
284
  * // => 0
311
285
  * ```
312
- *
313
- * @category Getters
314
286
  */
315
287
  declare const unwrapOr: OptionUnwrapOr;
316
288
  /**
@@ -321,7 +293,7 @@ declare const unwrapOr: OptionUnwrapOr;
321
293
  * - Data-last: `pipe(option, unwrapOrElse(fn))`
322
294
  *
323
295
  * @param fn - Function to compute a value
324
- * @returns A function that takes an Option and returns the value or computed value
296
+ * @returns The unwrapped value in data-first form, or a function that unwraps an Option lazily in data-last form
325
297
  *
326
298
  * @example
327
299
  * ```ts
@@ -334,8 +306,6 @@ declare const unwrapOr: OptionUnwrapOr;
334
306
  * const dataLast = Option.unwrapOrElse(() => 0)(input)
335
307
  * // => 0
336
308
  * ```
337
- *
338
- * @category Getters
339
309
  */
340
310
  declare const unwrapOrElse: OptionUnwrapOrElse;
341
311
  /**
@@ -346,7 +316,7 @@ declare const unwrapOrElse: OptionUnwrapOrElse;
346
316
  * - Data-last: `pipe(option, match({ Some: ..., None: ... }))`
347
317
  *
348
318
  * @param handlers - Object with `Some` and `None` handlers
349
- * @returns A function that takes an Option and returns the handler result
319
+ * @returns The handler result in data-first form, or a function that matches an Option in data-last form
350
320
  *
351
321
  * @example
352
322
  * ```ts
@@ -365,8 +335,6 @@ declare const unwrapOrElse: OptionUnwrapOrElse;
365
335
  * })(input)
366
336
  * // => "some:2"
367
337
  * ```
368
- *
369
- * @category Pattern Matching
370
338
  */
371
339
  declare const match: OptionMatch;
372
340
  /**
@@ -379,8 +347,6 @@ declare const match: OptionMatch;
379
347
  * const value = Option.fromNullable("Ada")
380
348
  * // => { _tag: "Some", value: "Ada" }
381
349
  * ```
382
- *
383
- * @category Conversions
384
350
  */
385
351
  declare const fromNullable: <T>(value: T) => Option$1<NonNullable<T>>;
386
352
  /**
@@ -406,10 +372,8 @@ declare const fromNullable: <T>(value: T) => Option$1<NonNullable<T>>;
406
372
  * const parsed = Option.fromTry(() => Number.parseInt("42", 10))
407
373
  * // => { _tag: "Some", value: 42 }
408
374
  * ```
409
- *
410
- * @category Conversions
411
375
  */
412
376
  declare const fromTry: <T>(fn: () => T) => FromTryReturn<T>;
413
377
  //#endregion
414
378
  export { option_d_exports as t };
415
- //# sourceMappingURL=index-UzMbg1dh.d.mts.map
379
+ //# sourceMappingURL=index-BqJ1GWAF.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BqJ1GWAF.d.mts","names":[],"sources":["../src/option/option.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;cA0Da,2BAAkB;;;;;;;;;;AAA/B;AAYY,KAAA,kBAAA,GAAqB,YAAoB,CAAA,OAAA,oBAAR,CAAA;AAY7C;AAsBA;;;;;AA4BA;AAgCA;;;AAA+E,KAlFnE,MAkFmE,CAAA,CAAA,CAAA,GAlFvD,QAkFuD,CAlF5C,CAkF4C,CAAA;;;;AAc/E;;;;;;;AAmCA;AAsCA;AAsCA;AAsCA;AA4Ba,cA3PA,IA8PX,EAHmB,CAAA,CAAA,CAAA,CAAA,KAAA,EA3PU,CA8P7B,EAAA,GA9PiC,QA8PjC,CA9P4C,CA8P5C,CAAA;AAyBF;AAgDA;AA2BA;AAiCA;AAyCA;;;;;;AA2BA;;;AAAyC,cA3a5B,IA2a4B,EAAA,CAAA,IAAA,KAAA,CAAA,GAAA,GA3aN,QA2aM,CA3aK,CA2aL,CAAA;;;;;;;;;;;;;;;cA3Y5B,oBAAqB,SAAW,iBAAe,QAAQ,SAAW;;;;;;;;;;;;;;cAclE,oBAAqB,SAAW,iBAAe,QAAQ,SAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmClE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCL,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCT,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCL,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;cA4BR,QAAQ;;;;;;;;;;;;;;;;;;;cA4BR,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;cAgDL,UAAU;;;;;;;;;;;;;;;;;;;;;;;cA2BV,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCd,OAAO;;;;;;;;;;;;cAyCP,yBAA0B,MAAI,SAAW,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;cA2BrD,uBAAwB,MAAI,cAAc"}
@@ -0,0 +1,96 @@
1
+ import { n as Branded } from "./brand.types-B3NDX1vo.mjs";
2
+ import { n as TaggedErrorFactory } from "./index-UINIHFuh.mjs";
3
+ import { t as Result } from "./index-CIvNgjsx.mjs";
4
+
5
+ //#region src/duration/duration.d.ts
6
+ declare namespace duration_d_exports {
7
+ export { Duration, DurationInvalidInputError, DurationInvalidValueError, DurationParseError, Input, InputError, ParseError, StringInput, Unit, days, from, hours, millis, minutes, parse, seconds, toMillis, weeks };
8
+ }
9
+ /**
10
+ * Millisecond-backed branded duration type.
11
+ */
12
+ type Duration = Branded<number, "Duration">;
13
+ /**
14
+ * Supported textual duration units.
15
+ */
16
+ type Unit = "milli" | "millis" | "second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days" | "week" | "weeks";
17
+ /**
18
+ * String input for durations.
19
+ */
20
+ type StringInput = `${number} ${Unit}`;
21
+ /**
22
+ * Accepted duration input shapes.
23
+ */
24
+ type Input = Duration | number | StringInput;
25
+ declare const DurationParseError_base: TaggedErrorFactory<"DurationParseError">;
26
+ /**
27
+ * Tagged parse error for invalid duration strings.
28
+ */
29
+ declare class DurationParseError extends DurationParseError_base<{
30
+ input: string;
31
+ message: string;
32
+ }> {}
33
+ declare const DurationInvalidValueError_base: TaggedErrorFactory<"DurationInvalidValueError">;
34
+ /**
35
+ * Tagged error for invalid numeric duration values.
36
+ */
37
+ declare class DurationInvalidValueError extends DurationInvalidValueError_base<{
38
+ input: number;
39
+ message: string;
40
+ }> {}
41
+ declare const DurationInvalidInputError_base: TaggedErrorFactory<"DurationInvalidInputError">;
42
+ /**
43
+ * Tagged error for invalid duration input values outside supported shapes.
44
+ */
45
+ declare class DurationInvalidInputError extends DurationInvalidInputError_base<{
46
+ input: Input;
47
+ message: string;
48
+ cause?: DurationParseError | DurationInvalidValueError;
49
+ }> {}
50
+ /**
51
+ * Re-exported parse error type.
52
+ */
53
+ type ParseError = DurationParseError;
54
+ /**
55
+ * Re-exported duration input error union.
56
+ */
57
+ type InputError = DurationInvalidInputError | DurationParseError | DurationInvalidValueError;
58
+ /**
59
+ * Create a duration from milliseconds.
60
+ */
61
+ declare const millis: (value: number) => Duration;
62
+ /**
63
+ * Create a duration from seconds.
64
+ */
65
+ declare const seconds: (value: number) => Duration;
66
+ /**
67
+ * Create a duration from minutes.
68
+ */
69
+ declare const minutes: (value: number) => Duration;
70
+ /**
71
+ * Create a duration from hours.
72
+ */
73
+ declare const hours: (value: number) => Duration;
74
+ /**
75
+ * Create a duration from days.
76
+ */
77
+ declare const days: (value: number) => Duration;
78
+ /**
79
+ * Create a duration from weeks.
80
+ */
81
+ declare const weeks: (value: number) => Duration;
82
+ /**
83
+ * Convert a duration to raw milliseconds.
84
+ */
85
+ declare const toMillis: (duration: Duration) => number;
86
+ /**
87
+ * Parse a duration string.
88
+ */
89
+ declare const parse: (input: string) => Result<Duration, DurationParseError>;
90
+ /**
91
+ * Normalize supported duration inputs to a branded duration.
92
+ */
93
+ declare const from: (input: Input) => Result<Duration, InputError>;
94
+ //#endregion
95
+ export { InputError as n, duration_d_exports as r, Input as t };
96
+ //# sourceMappingURL=index-BsPOcZk9.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BsPOcZk9.d.mts","names":[],"sources":["../src/duration/duration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KA4BY,QAAA,GAAW;;;;KAKX,IAAA;;;;KAiBA,WAAA,gBAA2B;;;;KAK3B,KAAA,GAAQ,oBAAoB;cAAW,yBAAA;;;;cAKtC,kBAAA,SAA2B;;;AAhCxC,CAAA,CAAA,CAAA;AAsBA,cAaK,8BAbsC,EAatC,kBAbsC,CAAA,2BAAA,CAAA;AAK3C;AAAmD;AAKnD;AAGK,cAKQ,yBAAA,SAAkC,8BAL1C,CAAA;EAKQ,KAAA,EAAA,MAAA;EAGR,OAAA,EAAA,MAAA;AAKL,CAAA,CAAA,CAAA;cALK,8BAQK,EARL,kBAQK,CAAA,2BAAA,CAAA;;;;AAME,cATC,yBAAA,SAAkC,8BASJ,CAAA;EAK/B,KAAA,EAbH,KAaG;EAAa,OAAA,EAAA,MAAA;EAA4B,KAAA,CAAA,EAX3C,kBAW2C,GAXtB,yBAWsB;CAAqB,CAAA,CAAA;AAwB1E;AAKA;AAKA;AAKa,KA5CD,UAAA,GAAa,kBA4CkD;AAK3E;AAKA;AAKA;AAiCa,KAvFD,UAAA,GAAa,yBAkHxB,GAlHoD,kBAkHpD,GAlHyE,yBAkHzE;;;;AA3BkD,cA/DtC,MA+DsC,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GA/DZ,QA+DY;AAgCnD;;;AAA4D,cA1F/C,OA0F+C,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GA1FpB,QA0FoB;;;;cArF/C,4BAA2B;;;;cAK3B,0BAAyB;;;;cAKzB,yBAAwB;;;;cAKxB,0BAAyB;;;;cAKzB,qBAAsB;;;;cAiCtB,0BAAyB,OAAc,UAAU;;;;cAgCjD,cAAe,UAAQ,OAAc,UAAU"}