@nlozgachev/pipelined 0.12.0 → 0.13.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 (205) hide show
  1. package/LICENCE +28 -0
  2. package/README.md +1 -1
  3. package/{types/src/Types/NonEmptyList.d.ts → dist/NonEmptyList-BlGFjor5.d.mts} +4 -3
  4. package/dist/NonEmptyList-BlGFjor5.d.ts +30 -0
  5. package/dist/Task-BB8Wmc1J.d.ts +677 -0
  6. package/dist/Task-ChKyH0pF.d.mts +677 -0
  7. package/dist/chunk-DBIC62UV.mjs +6 -0
  8. package/dist/chunk-QPTGO5AS.mjs +150 -0
  9. package/dist/composition.d.mts +495 -0
  10. package/dist/composition.d.ts +495 -0
  11. package/dist/composition.js +188 -0
  12. package/dist/composition.mjs +135 -0
  13. package/dist/core.d.mts +2170 -0
  14. package/dist/core.d.ts +2170 -0
  15. package/dist/core.js +698 -0
  16. package/dist/core.mjs +517 -0
  17. package/dist/types.d.mts +54 -0
  18. package/{types/src/Types/Brand.d.ts → dist/types.d.ts} +6 -4
  19. package/dist/types.js +41 -0
  20. package/dist/types.mjs +14 -0
  21. package/dist/utils.d.mts +1285 -0
  22. package/dist/utils.d.ts +1285 -0
  23. package/dist/utils.js +722 -0
  24. package/dist/utils.mjs +553 -0
  25. package/package.json +63 -69
  26. package/esm/mod.js +0 -3
  27. package/esm/package.json +0 -3
  28. package/esm/src/Composition/compose.js +0 -3
  29. package/esm/src/Composition/converge.js +0 -3
  30. package/esm/src/Composition/curry.js +0 -42
  31. package/esm/src/Composition/flip.js +0 -20
  32. package/esm/src/Composition/flow.js +0 -8
  33. package/esm/src/Composition/fn.js +0 -85
  34. package/esm/src/Composition/index.js +0 -13
  35. package/esm/src/Composition/juxt.js +0 -3
  36. package/esm/src/Composition/memoize.js +0 -66
  37. package/esm/src/Composition/not.js +0 -25
  38. package/esm/src/Composition/on.js +0 -12
  39. package/esm/src/Composition/pipe.js +0 -3
  40. package/esm/src/Composition/tap.js +0 -33
  41. package/esm/src/Composition/uncurry.js +0 -32
  42. package/esm/src/Core/Deferred.js +0 -30
  43. package/esm/src/Core/InternalTypes.js +0 -1
  44. package/esm/src/Core/Lens.js +0 -98
  45. package/esm/src/Core/Logged.js +0 -111
  46. package/esm/src/Core/Option.js +0 -191
  47. package/esm/src/Core/Optional.js +0 -160
  48. package/esm/src/Core/Predicate.js +0 -133
  49. package/esm/src/Core/Reader.js +0 -134
  50. package/esm/src/Core/Refinement.js +0 -115
  51. package/esm/src/Core/RemoteData.js +0 -211
  52. package/esm/src/Core/Result.js +0 -170
  53. package/esm/src/Core/State.js +0 -181
  54. package/esm/src/Core/Task.js +0 -223
  55. package/esm/src/Core/TaskOption.js +0 -106
  56. package/esm/src/Core/TaskResult.js +0 -127
  57. package/esm/src/Core/TaskValidation.js +0 -128
  58. package/esm/src/Core/These.js +0 -245
  59. package/esm/src/Core/Tuple.js +0 -112
  60. package/esm/src/Core/Validation.js +0 -212
  61. package/esm/src/Core/index.js +0 -18
  62. package/esm/src/Types/Brand.js +0 -28
  63. package/esm/src/Types/NonEmptyList.js +0 -14
  64. package/esm/src/Types/index.js +0 -2
  65. package/esm/src/Utils/Arr.js +0 -570
  66. package/esm/src/Utils/Dict.js +0 -421
  67. package/esm/src/Utils/Num.js +0 -124
  68. package/esm/src/Utils/Rec.js +0 -241
  69. package/esm/src/Utils/Str.js +0 -134
  70. package/esm/src/Utils/Uniq.js +0 -265
  71. package/esm/src/Utils/index.js +0 -6
  72. package/script/mod.js +0 -19
  73. package/script/package.json +0 -3
  74. package/script/src/Composition/compose.js +0 -6
  75. package/script/src/Composition/converge.js +0 -6
  76. package/script/src/Composition/curry.js +0 -48
  77. package/script/src/Composition/flip.js +0 -24
  78. package/script/src/Composition/flow.js +0 -11
  79. package/script/src/Composition/fn.js +0 -98
  80. package/script/src/Composition/index.js +0 -29
  81. package/script/src/Composition/juxt.js +0 -6
  82. package/script/src/Composition/memoize.js +0 -71
  83. package/script/src/Composition/not.js +0 -29
  84. package/script/src/Composition/on.js +0 -16
  85. package/script/src/Composition/pipe.js +0 -6
  86. package/script/src/Composition/tap.js +0 -37
  87. package/script/src/Composition/uncurry.js +0 -38
  88. package/script/src/Core/Deferred.js +0 -33
  89. package/script/src/Core/InternalTypes.js +0 -2
  90. package/script/src/Core/Lens.js +0 -101
  91. package/script/src/Core/Logged.js +0 -114
  92. package/script/src/Core/Option.js +0 -194
  93. package/script/src/Core/Optional.js +0 -163
  94. package/script/src/Core/Predicate.js +0 -136
  95. package/script/src/Core/Reader.js +0 -137
  96. package/script/src/Core/Refinement.js +0 -118
  97. package/script/src/Core/RemoteData.js +0 -214
  98. package/script/src/Core/Result.js +0 -173
  99. package/script/src/Core/State.js +0 -184
  100. package/script/src/Core/Task.js +0 -226
  101. package/script/src/Core/TaskOption.js +0 -109
  102. package/script/src/Core/TaskResult.js +0 -130
  103. package/script/src/Core/TaskValidation.js +0 -131
  104. package/script/src/Core/These.js +0 -248
  105. package/script/src/Core/Tuple.js +0 -115
  106. package/script/src/Core/Validation.js +0 -215
  107. package/script/src/Core/index.js +0 -34
  108. package/script/src/Types/Brand.js +0 -31
  109. package/script/src/Types/NonEmptyList.js +0 -18
  110. package/script/src/Types/index.js +0 -18
  111. package/script/src/Utils/Arr.js +0 -573
  112. package/script/src/Utils/Dict.js +0 -424
  113. package/script/src/Utils/Num.js +0 -127
  114. package/script/src/Utils/Rec.js +0 -244
  115. package/script/src/Utils/Str.js +0 -137
  116. package/script/src/Utils/Uniq.js +0 -268
  117. package/script/src/Utils/index.js +0 -22
  118. package/types/mod.d.ts +0 -4
  119. package/types/mod.d.ts.map +0 -1
  120. package/types/src/Composition/compose.d.ts +0 -33
  121. package/types/src/Composition/compose.d.ts.map +0 -1
  122. package/types/src/Composition/converge.d.ts +0 -21
  123. package/types/src/Composition/converge.d.ts.map +0 -1
  124. package/types/src/Composition/curry.d.ts +0 -43
  125. package/types/src/Composition/curry.d.ts.map +0 -1
  126. package/types/src/Composition/flip.d.ts +0 -21
  127. package/types/src/Composition/flip.d.ts.map +0 -1
  128. package/types/src/Composition/flow.d.ts +0 -56
  129. package/types/src/Composition/flow.d.ts.map +0 -1
  130. package/types/src/Composition/fn.d.ts +0 -76
  131. package/types/src/Composition/fn.d.ts.map +0 -1
  132. package/types/src/Composition/index.d.ts +0 -14
  133. package/types/src/Composition/index.d.ts.map +0 -1
  134. package/types/src/Composition/juxt.d.ts +0 -18
  135. package/types/src/Composition/juxt.d.ts.map +0 -1
  136. package/types/src/Composition/memoize.d.ts +0 -46
  137. package/types/src/Composition/memoize.d.ts.map +0 -1
  138. package/types/src/Composition/not.d.ts +0 -26
  139. package/types/src/Composition/not.d.ts.map +0 -1
  140. package/types/src/Composition/on.d.ts +0 -13
  141. package/types/src/Composition/on.d.ts.map +0 -1
  142. package/types/src/Composition/pipe.d.ts +0 -56
  143. package/types/src/Composition/pipe.d.ts.map +0 -1
  144. package/types/src/Composition/tap.d.ts +0 -31
  145. package/types/src/Composition/tap.d.ts.map +0 -1
  146. package/types/src/Composition/uncurry.d.ts +0 -54
  147. package/types/src/Composition/uncurry.d.ts.map +0 -1
  148. package/types/src/Core/Deferred.d.ts +0 -49
  149. package/types/src/Core/Deferred.d.ts.map +0 -1
  150. package/types/src/Core/InternalTypes.d.ts +0 -23
  151. package/types/src/Core/InternalTypes.d.ts.map +0 -1
  152. package/types/src/Core/Lens.d.ts +0 -118
  153. package/types/src/Core/Lens.d.ts.map +0 -1
  154. package/types/src/Core/Logged.d.ts +0 -126
  155. package/types/src/Core/Logged.d.ts.map +0 -1
  156. package/types/src/Core/Option.d.ts +0 -209
  157. package/types/src/Core/Option.d.ts.map +0 -1
  158. package/types/src/Core/Optional.d.ts +0 -158
  159. package/types/src/Core/Optional.d.ts.map +0 -1
  160. package/types/src/Core/Predicate.d.ts +0 -161
  161. package/types/src/Core/Predicate.d.ts.map +0 -1
  162. package/types/src/Core/Reader.d.ts +0 -156
  163. package/types/src/Core/Reader.d.ts.map +0 -1
  164. package/types/src/Core/Refinement.d.ts +0 -138
  165. package/types/src/Core/Refinement.d.ts.map +0 -1
  166. package/types/src/Core/RemoteData.d.ts +0 -197
  167. package/types/src/Core/RemoteData.d.ts.map +0 -1
  168. package/types/src/Core/Result.d.ts +0 -182
  169. package/types/src/Core/Result.d.ts.map +0 -1
  170. package/types/src/Core/State.d.ts +0 -192
  171. package/types/src/Core/State.d.ts.map +0 -1
  172. package/types/src/Core/Task.d.ts +0 -219
  173. package/types/src/Core/Task.d.ts.map +0 -1
  174. package/types/src/Core/TaskOption.d.ts +0 -121
  175. package/types/src/Core/TaskOption.d.ts.map +0 -1
  176. package/types/src/Core/TaskResult.d.ts +0 -119
  177. package/types/src/Core/TaskResult.d.ts.map +0 -1
  178. package/types/src/Core/TaskValidation.d.ts +0 -144
  179. package/types/src/Core/TaskValidation.d.ts.map +0 -1
  180. package/types/src/Core/These.d.ts +0 -225
  181. package/types/src/Core/These.d.ts.map +0 -1
  182. package/types/src/Core/Tuple.d.ts +0 -129
  183. package/types/src/Core/Tuple.d.ts.map +0 -1
  184. package/types/src/Core/Validation.d.ts +0 -203
  185. package/types/src/Core/Validation.d.ts.map +0 -1
  186. package/types/src/Core/index.d.ts +0 -19
  187. package/types/src/Core/index.d.ts.map +0 -1
  188. package/types/src/Types/Brand.d.ts.map +0 -1
  189. package/types/src/Types/NonEmptyList.d.ts.map +0 -1
  190. package/types/src/Types/index.d.ts +0 -3
  191. package/types/src/Types/index.d.ts.map +0 -1
  192. package/types/src/Utils/Arr.d.ts +0 -403
  193. package/types/src/Utils/Arr.d.ts.map +0 -1
  194. package/types/src/Utils/Dict.d.ts +0 -310
  195. package/types/src/Utils/Dict.d.ts.map +0 -1
  196. package/types/src/Utils/Num.d.ts +0 -110
  197. package/types/src/Utils/Num.d.ts.map +0 -1
  198. package/types/src/Utils/Rec.d.ts +0 -159
  199. package/types/src/Utils/Rec.d.ts.map +0 -1
  200. package/types/src/Utils/Str.d.ts +0 -128
  201. package/types/src/Utils/Str.d.ts.map +0 -1
  202. package/types/src/Utils/Uniq.d.ts +0 -179
  203. package/types/src/Utils/Uniq.d.ts.map +0 -1
  204. package/types/src/Utils/index.d.ts +0 -7
  205. package/types/src/Utils/index.d.ts.map +0 -1
@@ -1,197 +0,0 @@
1
- import { WithError, WithKind, WithValue } from "./InternalTypes.js";
2
- import { Option } from "./Option.js";
3
- import { Result } from "./Result.js";
4
- /**
5
- * RemoteData represents the state of an async data fetch.
6
- * It has four states: NotAsked, Loading, Failure, and Success.
7
- *
8
- * Use RemoteData to model data fetching states explicitly,
9
- * replacing the common `{ data: T | null; loading: boolean; error: Error | null }` pattern.
10
- *
11
- * @example
12
- * ```ts
13
- * const renderUser = pipe(
14
- * userData,
15
- * RemoteData.match({
16
- * notAsked: () => "Click to load",
17
- * loading: () => "Loading...",
18
- * failure: e => `Error: ${e.message}`,
19
- * success: user => `Hello, ${user.name}!`
20
- * })
21
- * );
22
- * ```
23
- */
24
- export type RemoteData<E, A> = NotAsked | Loading | Failure<E> | Success<A>;
25
- export type NotAsked = WithKind<"NotAsked">;
26
- export type Loading = WithKind<"Loading">;
27
- export type Failure<E> = WithKind<"Failure"> & WithError<E>;
28
- export type Success<A> = WithKind<"Success"> & WithValue<A>;
29
- export declare namespace RemoteData {
30
- /**
31
- * Creates a NotAsked RemoteData.
32
- */
33
- const notAsked: <E, A>() => RemoteData<E, A>;
34
- /**
35
- * Creates a Loading RemoteData.
36
- */
37
- const loading: <E, A>() => RemoteData<E, A>;
38
- /**
39
- * Creates a Failure RemoteData with the given error.
40
- */
41
- const failure: <E, A>(error: E) => RemoteData<E, A>;
42
- /**
43
- * Creates a Success RemoteData with the given value.
44
- */
45
- const success: <E, A>(value: A) => RemoteData<E, A>;
46
- /**
47
- * Type guard that checks if a RemoteData is NotAsked.
48
- */
49
- const isNotAsked: <E, A>(data: RemoteData<E, A>) => data is NotAsked;
50
- /**
51
- * Type guard that checks if a RemoteData is Loading.
52
- */
53
- const isLoading: <E, A>(data: RemoteData<E, A>) => data is Loading;
54
- /**
55
- * Type guard that checks if a RemoteData is Failure.
56
- */
57
- const isFailure: <E, A>(data: RemoteData<E, A>) => data is Failure<E>;
58
- /**
59
- * Type guard that checks if a RemoteData is Success.
60
- */
61
- const isSuccess: <E, A>(data: RemoteData<E, A>) => data is Success<A>;
62
- /**
63
- * Transforms the success value inside a RemoteData.
64
- *
65
- * @example
66
- * ```ts
67
- * pipe(RemoteData.success(5), RemoteData.map(n => n * 2)); // Success(10)
68
- * pipe(RemoteData.loading(), RemoteData.map(n => n * 2)); // Loading
69
- * ```
70
- */
71
- const map: <A, B>(f: (a: A) => B) => <E>(data: RemoteData<E, A>) => RemoteData<E, B>;
72
- /**
73
- * Transforms the error value inside a RemoteData.
74
- *
75
- * @example
76
- * ```ts
77
- * pipe(RemoteData.failure("oops"), RemoteData.mapError(e => e.toUpperCase())); // Failure("OOPS")
78
- * ```
79
- */
80
- const mapError: <E, F>(f: (e: E) => F) => <A>(data: RemoteData<E, A>) => RemoteData<F, A>;
81
- /**
82
- * Chains RemoteData computations. If the input is Success, passes the value to f.
83
- * Otherwise, propagates the current state.
84
- *
85
- * @example
86
- * ```ts
87
- * pipe(
88
- * RemoteData.success(5),
89
- * RemoteData.chain(n => n > 0 ? RemoteData.success(n) : RemoteData.failure("negative"))
90
- * );
91
- * ```
92
- */
93
- const chain: <E, A, B>(f: (a: A) => RemoteData<E, B>) => (data: RemoteData<E, A>) => RemoteData<E, B>;
94
- /**
95
- * Applies a function wrapped in a RemoteData to a value wrapped in a RemoteData.
96
- *
97
- * @example
98
- * ```ts
99
- * const add = (a: number) => (b: number) => a + b;
100
- * pipe(
101
- * RemoteData.success(add),
102
- * RemoteData.ap(RemoteData.success(5)),
103
- * RemoteData.ap(RemoteData.success(3))
104
- * ); // Success(8)
105
- * ```
106
- */
107
- const ap: <E, A>(arg: RemoteData<E, A>) => <B>(data: RemoteData<E, (a: A) => B>) => RemoteData<E, B>;
108
- /**
109
- * Extracts the value from a RemoteData by providing handlers for all four cases.
110
- *
111
- * @example
112
- * ```ts
113
- * pipe(
114
- * userData,
115
- * RemoteData.fold(
116
- * () => "Not asked",
117
- * () => "Loading...",
118
- * e => `Error: ${e}`,
119
- * value => `Got: ${value}`
120
- * )
121
- * );
122
- * ```
123
- */
124
- const fold: <E, A, B>(onNotAsked: () => B, onLoading: () => B, onFailure: (e: E) => B, onSuccess: (a: A) => B) => (data: RemoteData<E, A>) => B;
125
- /**
126
- * Pattern matches on a RemoteData, returning the result of the matching case.
127
- *
128
- * @example
129
- * ```ts
130
- * pipe(
131
- * userData,
132
- * RemoteData.match({
133
- * notAsked: () => "Click to load",
134
- * loading: () => "Loading...",
135
- * failure: e => `Error: ${e}`,
136
- * success: user => `Hello, ${user.name}!`
137
- * })
138
- * );
139
- * ```
140
- */
141
- const match: <E, A, B>(cases: {
142
- notAsked: () => B;
143
- loading: () => B;
144
- failure: (e: E) => B;
145
- success: (a: A) => B;
146
- }) => (data: RemoteData<E, A>) => B;
147
- /**
148
- * Returns the success value or a default value if the RemoteData is not Success.
149
- * The default can be a different type, widening the result to `A | B`.
150
- *
151
- * @example
152
- * ```ts
153
- * pipe(RemoteData.success(5), RemoteData.getOrElse(() => 0)); // 5
154
- * pipe(RemoteData.loading(), RemoteData.getOrElse(() => 0)); // 0
155
- * pipe(RemoteData.loading<string, number>(), RemoteData.getOrElse(() => null)); // null — typed as number | null
156
- * ```
157
- */
158
- const getOrElse: <E, A, B>(defaultValue: () => B) => (data: RemoteData<E, A>) => A | B;
159
- /**
160
- * Executes a side effect on the success value without changing the RemoteData.
161
- *
162
- * @example
163
- * ```ts
164
- * pipe(
165
- * RemoteData.success(5),
166
- * RemoteData.tap(n => console.log("Value:", n)),
167
- * RemoteData.map(n => n * 2)
168
- * );
169
- * ```
170
- */
171
- const tap: <E, A>(f: (a: A) => void) => (data: RemoteData<E, A>) => RemoteData<E, A>;
172
- /**
173
- * Recovers from a Failure state by providing a fallback RemoteData.
174
- * The fallback can produce a different success type, widening the result to `RemoteData<E, A | B>`.
175
- */
176
- const recover: <E, A, B>(fallback: (e: E) => RemoteData<E, B>) => (data: RemoteData<E, A>) => RemoteData<E, A | B>;
177
- /**
178
- * Converts a RemoteData to an Option.
179
- * Success becomes Some, all other states become None.
180
- */
181
- const toOption: <E, A>(data: RemoteData<E, A>) => Option<A>;
182
- /**
183
- * Converts a RemoteData to a Result.
184
- * Success becomes Ok, Failure becomes Err.
185
- * NotAsked and Loading become Err with the provided fallback error.
186
- *
187
- * @example
188
- * ```ts
189
- * pipe(
190
- * RemoteData.success(42),
191
- * RemoteData.toResult(() => "not loaded")
192
- * ); // Ok(42)
193
- * ```
194
- */
195
- const toResult: <E>(onNotReady: () => E) => <A>(data: RemoteData<E, A>) => Result<E, A>;
196
- }
197
- //# sourceMappingURL=RemoteData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RemoteData.d.ts","sourceRoot":"","sources":["../../../src/src/Core/RemoteData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC5C,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC1C,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC5D,MAAM,MAAM,OAAO,CAAC,CAAC,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;CACnG"}
@@ -1,182 +0,0 @@
1
- import { WithError, WithKind, WithValue } from "./InternalTypes.js";
2
- import { Option } from "./Option.js";
3
- /**
4
- * Result represents a value that can be one of two types: a success (Ok) or a failure (Err).
5
- * Use Result when an operation can fail with a meaningful error value.
6
- *
7
- * @example
8
- * ```ts
9
- * const divide = (a: number, b: number): Result<string, number> =>
10
- * b === 0 ? Result.err("Division by zero") : Result.ok(a / b);
11
- *
12
- * pipe(
13
- * divide(10, 2),
14
- * Result.map(n => n * 2),
15
- * Result.getOrElse(() => 0)
16
- * ); // 10
17
- * ```
18
- */
19
- export type Result<E, A> = Ok<A> | Err<E>;
20
- export type Ok<A> = WithKind<"Ok"> & WithValue<A>;
21
- export type Err<E> = WithKind<"Error"> & WithError<E>;
22
- export declare namespace Result {
23
- /**
24
- * Creates a successful Result with the given value.
25
- */
26
- const ok: <A>(value: A) => Ok<A>;
27
- /**
28
- * Creates a failed Result with the given error.
29
- */
30
- const err: <E>(error: E) => Err<E>;
31
- /**
32
- * Type guard that checks if an Result is Ok.
33
- */
34
- const isOk: <E, A>(data: Result<E, A>) => data is Ok<A>;
35
- /**
36
- * Type guard that checks if an Result is Err.
37
- */
38
- const isErr: <E, A>(data: Result<E, A>) => data is Err<E>;
39
- /**
40
- * Creates an Result from a function that may throw.
41
- * Catches any errors and transforms them using the onError function.
42
- *
43
- * @example
44
- * ```ts
45
- * const parseJson = (s: string): Result<string, unknown> =>
46
- * Result.tryCatch(
47
- * () => JSON.parse(s),
48
- * (e) => `Parse error: ${e}`
49
- * );
50
- * ```
51
- */
52
- const tryCatch: <E, A>(f: () => A, onError: (e: unknown) => E) => Result<E, A>;
53
- /**
54
- * Transforms the success value inside an Result.
55
- *
56
- * @example
57
- * ```ts
58
- * pipe(Result.ok(5), Result.map(n => n * 2)); // Ok(10)
59
- * pipe(Result.err("error"), Result.map(n => n * 2)); // Err("error")
60
- * ```
61
- */
62
- const map: <E, A, B>(f: (a: A) => B) => (data: Result<E, A>) => Result<E, B>;
63
- /**
64
- * Transforms the error value inside an Result.
65
- *
66
- * @example
67
- * ```ts
68
- * pipe(Result.err("oops"), Result.mapError(e => e.toUpperCase())); // Err("OOPS")
69
- * ```
70
- */
71
- const mapError: <E, F, A>(f: (e: E) => F) => (data: Result<E, A>) => Result<F, A>;
72
- /**
73
- * Chains Result computations. If the first is Ok, passes the value to f.
74
- * If the first is Err, propagates the error.
75
- *
76
- * @example
77
- * ```ts
78
- * const validatePositive = (n: number): Result<string, number> =>
79
- * n > 0 ? Result.ok(n) : Result.err("Must be positive");
80
- *
81
- * pipe(Result.ok(5), Result.chain(validatePositive)); // Ok(5)
82
- * pipe(Result.ok(-1), Result.chain(validatePositive)); // Err("Must be positive")
83
- * ```
84
- */
85
- const chain: <E, A, B>(f: (a: A) => Result<E, B>) => (data: Result<E, A>) => Result<E, B>;
86
- /**
87
- * Extracts the value from an Result by providing handlers for both cases.
88
- *
89
- * @example
90
- * ```ts
91
- * pipe(
92
- * Result.ok(5),
93
- * Result.fold(
94
- * e => `Error: ${e}`,
95
- * n => `Value: ${n}`
96
- * )
97
- * ); // "Value: 5"
98
- * ```
99
- */
100
- const fold: <E, A, B>(onErr: (e: E) => B, onOk: (a: A) => B) => (data: Result<E, A>) => B;
101
- /**
102
- * Pattern matches on a Result, returning the result of the matching case.
103
- *
104
- * @example
105
- * ```ts
106
- * pipe(
107
- * result,
108
- * Result.match({
109
- * ok: value => `Got ${value}`,
110
- * err: error => `Failed: ${error}`
111
- * })
112
- * );
113
- * ```
114
- */
115
- const match: <E, A, B>(cases: {
116
- ok: (a: A) => B;
117
- err: (e: E) => B;
118
- }) => (data: Result<E, A>) => B;
119
- /**
120
- * Returns the success value or a default value if the Result is an error.
121
- * The default is a thunk `() => B` — evaluated only when the Result is Err.
122
- * The default can be a different type, widening the result to `A | B`.
123
- *
124
- * @example
125
- * ```ts
126
- * pipe(Result.ok(5), Result.getOrElse(() => 0)); // 5
127
- * pipe(Result.err("error"), Result.getOrElse(() => 0)); // 0
128
- * pipe(Result.err("error"), Result.getOrElse(() => null)); // null — typed as number | null
129
- * ```
130
- */
131
- const getOrElse: <E, A, B>(defaultValue: () => B) => (data: Result<E, A>) => A | B;
132
- /**
133
- * Executes a side effect on the success value without changing the Result.
134
- * Useful for logging or debugging.
135
- *
136
- * @example
137
- * ```ts
138
- * pipe(
139
- * Result.ok(5),
140
- * Result.tap(n => console.log("Value:", n)),
141
- * Result.map(n => n * 2)
142
- * );
143
- * ```
144
- */
145
- const tap: <E, A>(f: (a: A) => void) => (data: Result<E, A>) => Result<E, A>;
146
- /**
147
- * Recovers from an error by providing a fallback Result.
148
- * The fallback can produce a different success type, widening the result to `Result<E, A | B>`.
149
- */
150
- const recover: <E, A, B>(fallback: (e: E) => Result<E, B>) => (data: Result<E, A>) => Result<E, A | B>;
151
- /**
152
- * Recovers from an error unless it matches the blocked error.
153
- * The fallback can produce a different success type, widening the result to `Result<E, A | B>`.
154
- */
155
- const recoverUnless: <E, A, B>(blockedErr: E, fallback: () => Result<E, B>) => (data: Result<E, A>) => Result<E, A | B>;
156
- /**
157
- * Converts a Result to an Option.
158
- * Ok becomes Some, Err becomes None (the error is discarded).
159
- *
160
- * @example
161
- * ```ts
162
- * Result.toOption(Result.ok(42)); // Some(42)
163
- * Result.toOption(Result.err("oops")); // None
164
- * ```
165
- */
166
- const toOption: <E, A>(data: Result<E, A>) => Option<A>;
167
- /**
168
- * Applies a function wrapped in an Result to a value wrapped in an Result.
169
- *
170
- * @example
171
- * ```ts
172
- * const add = (a: number) => (b: number) => a + b;
173
- * pipe(
174
- * Result.ok(add),
175
- * Result.ap(Result.ok(5)),
176
- * Result.ap(Result.ok(3))
177
- * ); // Ok(8)
178
- * ```
179
- */
180
- const ap: <E, A>(arg: Result<E, A>) => <B>(data: Result<E, (a: A) => B>) => Result<E, B>;
181
- }
182
- //# sourceMappingURL=Result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Result.d.ts","sourceRoot":"","sources":["../../../src/src/Core/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MAAM,CAAC,CAAC,EAAE,CAAC,CACF,CAAC;CAC5F"}
@@ -1,192 +0,0 @@
1
- /**
2
- * A synchronous computation that threads a piece of mutable state `S` through
3
- * a pipeline without exposing mutation at call sites.
4
- *
5
- * At runtime a `State<S, A>` is just a function from an initial state to a pair
6
- * `[value, nextState]`. Nothing runs until you supply the initial state with
7
- * `State.run`, `State.evaluate`, or `State.execute`.
8
- *
9
- * @example
10
- * ```ts
11
- * type Counter = number;
12
- *
13
- * const increment: State<Counter, undefined> = State.modify(n => n + 1);
14
- * const getCount: State<Counter, Counter> = State.get();
15
- *
16
- * const program = pipe(
17
- * increment,
18
- * State.chain(() => increment),
19
- * State.chain(() => getCount),
20
- * );
21
- *
22
- * State.run(0)(program); // [2, 2] — value is 2, final state is 2
23
- * ```
24
- */
25
- export type State<S, A> = (s: S) => readonly [A, S];
26
- export declare namespace State {
27
- /**
28
- * Lifts a pure value into a State computation. The state passes through unchanged.
29
- *
30
- * @example
31
- * ```ts
32
- * State.run(10)(State.resolve(42)); // [42, 10] — value 42, state unchanged
33
- * ```
34
- */
35
- const resolve: <S, A>(value: A) => State<S, A>;
36
- /**
37
- * Produces the current state as the value, without modifying it.
38
- *
39
- * @example
40
- * ```ts
41
- * const readStack: State<string[], string[]> = State.get();
42
- * State.run(["a", "b"])(readStack); // [["a", "b"], ["a", "b"]]
43
- * ```
44
- */
45
- const get: <S>() => State<S, S>;
46
- /**
47
- * Reads a projection of the state without modifying it.
48
- * Equivalent to `pipe(State.get(), State.map(f))` but more direct.
49
- *
50
- * @example
51
- * ```ts
52
- * type AppState = { count: number; label: string };
53
- * const readCount: State<AppState, number> = State.gets(s => s.count);
54
- * State.run({ count: 5, label: "x" })(readCount); // [5, { count: 5, label: "x" }]
55
- * ```
56
- */
57
- const gets: <S, A>(f: (s: S) => A) => State<S, A>;
58
- /**
59
- * Replaces the current state with a new value. Produces no meaningful value.
60
- *
61
- * @example
62
- * ```ts
63
- * const reset: State<number, undefined> = State.put(0);
64
- * State.run(99)(reset); // [undefined, 0]
65
- * ```
66
- */
67
- const put: <S>(newState: S) => State<S, undefined>;
68
- /**
69
- * Applies a function to the current state to produce the next state.
70
- * Produces no meaningful value.
71
- *
72
- * @example
73
- * ```ts
74
- * const push = (item: string): State<string[], undefined> =>
75
- * State.modify(stack => [...stack, item]);
76
- *
77
- * State.run(["a"])(push("b")); // [undefined, ["a", "b"]]
78
- * ```
79
- */
80
- const modify: <S>(f: (s: S) => S) => State<S, undefined>;
81
- /**
82
- * Transforms the value produced by a State computation.
83
- * The state transformation is unchanged.
84
- *
85
- * @example
86
- * ```ts
87
- * const readLength: State<string[], number> = pipe(
88
- * State.get<string[]>(),
89
- * State.map(stack => stack.length),
90
- * );
91
- *
92
- * State.run(["a", "b", "c"])(readLength); // [3, ["a", "b", "c"]]
93
- * ```
94
- */
95
- const map: <S, A, B>(f: (a: A) => B) => (st: State<S, A>) => State<S, B>;
96
- /**
97
- * Sequences two State computations. The state output of the first is passed
98
- * as the state input to the second.
99
- *
100
- * Data-last — the first computation is the data being piped.
101
- *
102
- * @example
103
- * ```ts
104
- * const push = (item: string): State<string[], undefined> =>
105
- * State.modify(stack => [...stack, item]);
106
- *
107
- * const program = pipe(
108
- * push("a"),
109
- * State.chain(() => push("b")),
110
- * State.chain(() => State.get<string[]>()),
111
- * );
112
- *
113
- * State.evaluate([])(program); // ["a", "b"]
114
- * ```
115
- */
116
- const chain: <S, A, B>(f: (a: A) => State<S, B>) => (st: State<S, A>) => State<S, B>;
117
- /**
118
- * Applies a function wrapped in a State to a value wrapped in a State.
119
- * The function computation runs first; its output state is the input to the
120
- * argument computation.
121
- *
122
- * @example
123
- * ```ts
124
- * const addCounted = (n: number) => (m: number) => n + m;
125
- * const program = pipe(
126
- * State.resolve<number, typeof addCounted>(addCounted),
127
- * State.ap(State.gets((s: number) => s * 2)),
128
- * State.ap(State.gets((s: number) => s)),
129
- * );
130
- *
131
- * State.evaluate(3)(program); // 6 + 3 = 9
132
- * ```
133
- */
134
- const ap: <S, A>(arg: State<S, A>) => <B>(fn: State<S, (a: A) => B>) => State<S, B>;
135
- /**
136
- * Runs a side effect on the produced value without changing the State computation.
137
- *
138
- * @example
139
- * ```ts
140
- * pipe(
141
- * State.get<number>(),
142
- * State.tap(n => console.log("current:", n)),
143
- * State.chain(() => State.modify(n => n + 1)),
144
- * );
145
- * ```
146
- */
147
- const tap: <S, A>(f: (a: A) => void) => (st: State<S, A>) => State<S, A>;
148
- /**
149
- * Runs a State computation with an initial state, returning both the
150
- * produced value and the final state as a pair.
151
- *
152
- * Data-last — the computation is the data being piped.
153
- *
154
- * @example
155
- * ```ts
156
- * const program = pipe(
157
- * State.modify<number>(n => n + 1),
158
- * State.chain(() => State.get<number>()),
159
- * );
160
- *
161
- * State.run(0)(program); // [1, 1]
162
- * ```
163
- */
164
- const run: <S>(initialState: S) => <A>(st: State<S, A>) => readonly [A, S];
165
- /**
166
- * Runs a State computation with an initial state, returning only the
167
- * produced value (discarding the final state).
168
- *
169
- * @example
170
- * ```ts
171
- * State.evaluate([])(pipe(
172
- * State.modify<string[]>(s => [...s, "x"]),
173
- * State.chain(() => State.get<string[]>()),
174
- * )); // ["x"]
175
- * ```
176
- */
177
- const evaluate: <S>(initialState: S) => <A>(st: State<S, A>) => A;
178
- /**
179
- * Runs a State computation with an initial state, returning only the
180
- * final state (discarding the produced value).
181
- *
182
- * @example
183
- * ```ts
184
- * State.execute(0)(pipe(
185
- * State.modify<number>(n => n + 10),
186
- * State.chain(() => State.modify<number>(n => n * 2)),
187
- * )); // 20
188
- * ```
189
- */
190
- const execute: <S>(initialState: S) => <A>(st: State<S, A>) => S;
191
- }
192
- //# sourceMappingURL=State.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/src/Core/State.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC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