@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
package/dist/core.mjs ADDED
@@ -0,0 +1,517 @@
1
+ import {
2
+ Deferred,
3
+ Option,
4
+ Result,
5
+ Task
6
+ } from "./chunk-QPTGO5AS.mjs";
7
+
8
+ // src/Core/Lens.ts
9
+ var Lens;
10
+ ((Lens2) => {
11
+ Lens2.make = (get2, set2) => ({ get: get2, set: set2 });
12
+ Lens2.prop = () => (key) => (0, Lens2.make)(
13
+ (s) => s[key],
14
+ (a) => (s) => ({ ...s, [key]: a })
15
+ );
16
+ Lens2.get = (lens) => (s) => lens.get(s);
17
+ Lens2.set = (lens) => (a) => (s) => lens.set(a)(s);
18
+ Lens2.modify = (lens) => (f) => (s) => lens.set(f(lens.get(s)))(s);
19
+ Lens2.andThen = (inner) => (outer) => (0, Lens2.make)(
20
+ (s) => inner.get(outer.get(s)),
21
+ (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s)
22
+ );
23
+ Lens2.andThenOptional = (inner) => (outer) => ({
24
+ get: (s) => inner.get(outer.get(s)),
25
+ set: (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s)
26
+ });
27
+ Lens2.toOptional = (lens) => ({
28
+ get: (s) => ({ kind: "Some", value: lens.get(s) }),
29
+ set: lens.set
30
+ });
31
+ })(Lens || (Lens = {}));
32
+
33
+ // src/Core/Logged.ts
34
+ var Logged;
35
+ ((Logged2) => {
36
+ Logged2.make = (value) => ({ value, log: [] });
37
+ Logged2.tell = (entry) => ({ value: void 0, log: [entry] });
38
+ Logged2.map = (f) => (data) => ({
39
+ value: f(data.value),
40
+ log: data.log
41
+ });
42
+ Logged2.chain = (f) => (data) => {
43
+ const next = f(data.value);
44
+ return { value: next.value, log: [...data.log, ...next.log] };
45
+ };
46
+ Logged2.ap = (arg) => (data) => ({
47
+ value: data.value(arg.value),
48
+ log: [...data.log, ...arg.log]
49
+ });
50
+ Logged2.tap = (f) => (data) => {
51
+ f(data.value);
52
+ return data;
53
+ };
54
+ Logged2.run = (data) => [data.value, data.log];
55
+ })(Logged || (Logged = {}));
56
+
57
+ // src/Core/Optional.ts
58
+ var Optional;
59
+ ((Optional2) => {
60
+ Optional2.make = (get2, set2) => ({ get: get2, set: set2 });
61
+ Optional2.prop = () => (key) => (0, Optional2.make)(
62
+ (s) => {
63
+ const val = s[key];
64
+ return val !== null && val !== void 0 ? Option.some(val) : Option.none();
65
+ },
66
+ (a) => (s) => ({ ...s, [key]: a })
67
+ );
68
+ Optional2.index = (i) => (0, Optional2.make)(
69
+ (arr) => i >= 0 && i < arr.length ? Option.some(arr[i]) : Option.none(),
70
+ (a) => (arr) => {
71
+ if (i < 0 || i >= arr.length) return arr;
72
+ const copy = [...arr];
73
+ copy[i] = a;
74
+ return copy;
75
+ }
76
+ );
77
+ Optional2.get = (opt) => (s) => opt.get(s);
78
+ Optional2.set = (opt) => (a) => (s) => opt.set(a)(s);
79
+ Optional2.modify = (opt) => (f) => (s) => {
80
+ const val = opt.get(s);
81
+ return val.kind === "None" ? s : opt.set(f(val.value))(s);
82
+ };
83
+ Optional2.getOrElse = (opt) => (defaultValue) => (s) => {
84
+ const val = opt.get(s);
85
+ return val.kind === "Some" ? val.value : defaultValue();
86
+ };
87
+ Optional2.fold = (opt) => (onNone, onSome) => (s) => {
88
+ const val = opt.get(s);
89
+ return val.kind === "Some" ? onSome(val.value) : onNone();
90
+ };
91
+ Optional2.match = (opt) => (cases) => (s) => {
92
+ const val = opt.get(s);
93
+ return val.kind === "Some" ? cases.some(val.value) : cases.none();
94
+ };
95
+ Optional2.andThen = (inner) => (outer) => (0, Optional2.make)(
96
+ (s) => {
97
+ const mid = outer.get(s);
98
+ return mid.kind === "None" ? Option.none() : inner.get(mid.value);
99
+ },
100
+ (b) => (s) => {
101
+ const mid = outer.get(s);
102
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
103
+ }
104
+ );
105
+ Optional2.andThenLens = (inner) => (outer) => (0, Optional2.make)(
106
+ (s) => {
107
+ const mid = outer.get(s);
108
+ return mid.kind === "None" ? Option.none() : Option.some(inner.get(mid.value));
109
+ },
110
+ (b) => (s) => {
111
+ const mid = outer.get(s);
112
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
113
+ }
114
+ );
115
+ })(Optional || (Optional = {}));
116
+
117
+ // src/Core/Predicate.ts
118
+ var Predicate;
119
+ ((Predicate2) => {
120
+ Predicate2.not = (p) => (a) => !p(a);
121
+ Predicate2.and = (second) => (first) => (a) => first(a) && second(a);
122
+ Predicate2.or = (second) => (first) => (a) => first(a) || second(a);
123
+ Predicate2.using = (f) => (p) => (b) => p(f(b));
124
+ Predicate2.all = (predicates) => (a) => predicates.every((p) => p(a));
125
+ Predicate2.any = (predicates) => (a) => predicates.some((p) => p(a));
126
+ Predicate2.fromRefinement = (r) => r;
127
+ })(Predicate || (Predicate = {}));
128
+
129
+ // src/Core/Reader.ts
130
+ var Reader;
131
+ ((Reader2) => {
132
+ Reader2.resolve = (value) => (_env) => value;
133
+ Reader2.ask = () => (env) => env;
134
+ Reader2.asks = (f) => (env) => f(env);
135
+ Reader2.map = (f) => (data) => (env) => f(data(env));
136
+ Reader2.chain = (f) => (data) => (env) => f(data(env))(env);
137
+ Reader2.ap = (arg) => (data) => (env) => data(env)(arg(env));
138
+ Reader2.tap = (f) => (data) => (env) => {
139
+ const a = data(env);
140
+ f(a);
141
+ return a;
142
+ };
143
+ Reader2.local = (f) => (data) => (env) => data(f(env));
144
+ Reader2.run = (env) => (data) => data(env);
145
+ })(Reader || (Reader = {}));
146
+
147
+ // src/Core/Refinement.ts
148
+ var Refinement;
149
+ ((Refinement2) => {
150
+ Refinement2.make = (f) => f;
151
+ Refinement2.compose = (bc) => (ab) => (a) => ab(a) && bc(a);
152
+ Refinement2.and = (second) => (first) => (a) => first(a) && second(a);
153
+ Refinement2.or = (second) => (first) => (a) => first(a) || second(a);
154
+ Refinement2.toFilter = (r) => (a) => r(a) ? Option.some(a) : Option.none();
155
+ Refinement2.toResult = (r, onFail) => (a) => r(a) ? Result.ok(a) : Result.err(onFail(a));
156
+ })(Refinement || (Refinement = {}));
157
+
158
+ // src/Core/RemoteData.ts
159
+ var _notAsked = { kind: "NotAsked" };
160
+ var _loading = { kind: "Loading" };
161
+ var RemoteData;
162
+ ((RemoteData2) => {
163
+ RemoteData2.notAsked = () => _notAsked;
164
+ RemoteData2.loading = () => _loading;
165
+ RemoteData2.failure = (error) => ({
166
+ kind: "Failure",
167
+ error
168
+ });
169
+ RemoteData2.success = (value) => ({
170
+ kind: "Success",
171
+ value
172
+ });
173
+ RemoteData2.isNotAsked = (data) => data.kind === "NotAsked";
174
+ RemoteData2.isLoading = (data) => data.kind === "Loading";
175
+ RemoteData2.isFailure = (data) => data.kind === "Failure";
176
+ RemoteData2.isSuccess = (data) => data.kind === "Success";
177
+ RemoteData2.map = (f) => (data) => (0, RemoteData2.isSuccess)(data) ? (0, RemoteData2.success)(f(data.value)) : data;
178
+ RemoteData2.mapError = (f) => (data) => (0, RemoteData2.isFailure)(data) ? (0, RemoteData2.failure)(f(data.error)) : data;
179
+ RemoteData2.chain = (f) => (data) => (0, RemoteData2.isSuccess)(data) ? f(data.value) : data;
180
+ RemoteData2.ap = (arg) => (data) => {
181
+ if ((0, RemoteData2.isSuccess)(data) && (0, RemoteData2.isSuccess)(arg)) {
182
+ return (0, RemoteData2.success)(data.value(arg.value));
183
+ }
184
+ if ((0, RemoteData2.isFailure)(data)) return data;
185
+ if ((0, RemoteData2.isFailure)(arg)) return arg;
186
+ if ((0, RemoteData2.isLoading)(data) || (0, RemoteData2.isLoading)(arg)) return (0, RemoteData2.loading)();
187
+ return (0, RemoteData2.notAsked)();
188
+ };
189
+ RemoteData2.fold = (onNotAsked, onLoading, onFailure, onSuccess) => (data) => {
190
+ switch (data.kind) {
191
+ case "NotAsked":
192
+ return onNotAsked();
193
+ case "Loading":
194
+ return onLoading();
195
+ case "Failure":
196
+ return onFailure(data.error);
197
+ case "Success":
198
+ return onSuccess(data.value);
199
+ }
200
+ };
201
+ RemoteData2.match = (cases) => (data) => {
202
+ switch (data.kind) {
203
+ case "NotAsked":
204
+ return cases.notAsked();
205
+ case "Loading":
206
+ return cases.loading();
207
+ case "Failure":
208
+ return cases.failure(data.error);
209
+ case "Success":
210
+ return cases.success(data.value);
211
+ }
212
+ };
213
+ RemoteData2.getOrElse = (defaultValue) => (data) => (0, RemoteData2.isSuccess)(data) ? data.value : defaultValue();
214
+ RemoteData2.tap = (f) => (data) => {
215
+ if ((0, RemoteData2.isSuccess)(data)) f(data.value);
216
+ return data;
217
+ };
218
+ RemoteData2.recover = (fallback) => (data) => (0, RemoteData2.isFailure)(data) ? fallback(data.error) : data;
219
+ RemoteData2.toOption = (data) => (0, RemoteData2.isSuccess)(data) ? Option.some(data.value) : Option.none();
220
+ RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
221
+ })(RemoteData || (RemoteData = {}));
222
+
223
+ // src/Core/State.ts
224
+ var State;
225
+ ((State2) => {
226
+ State2.resolve = (value) => (s) => [value, s];
227
+ State2.get = () => (s) => [s, s];
228
+ State2.gets = (f) => (s) => [f(s), s];
229
+ State2.put = (newState) => (_s) => [void 0, newState];
230
+ State2.modify = (f) => (s) => [void 0, f(s)];
231
+ State2.map = (f) => (st) => (s) => {
232
+ const [a, s1] = st(s);
233
+ return [f(a), s1];
234
+ };
235
+ State2.chain = (f) => (st) => (s) => {
236
+ const [a, s1] = st(s);
237
+ return f(a)(s1);
238
+ };
239
+ State2.ap = (arg) => (fn) => (s) => {
240
+ const [f, s1] = fn(s);
241
+ const [a, s2] = arg(s1);
242
+ return [f(a), s2];
243
+ };
244
+ State2.tap = (f) => (st) => (s) => {
245
+ const [a, s1] = st(s);
246
+ f(a);
247
+ return [a, s1];
248
+ };
249
+ State2.run = (initialState) => (st) => st(initialState);
250
+ State2.evaluate = (initialState) => (st) => st(initialState)[0];
251
+ State2.execute = (initialState) => (st) => st(initialState)[1];
252
+ })(State || (State = {}));
253
+
254
+ // src/Core/TaskOption.ts
255
+ var TaskOption;
256
+ ((TaskOption2) => {
257
+ TaskOption2.some = (value) => Task.resolve(Option.some(value));
258
+ TaskOption2.none = () => Task.resolve(Option.none());
259
+ TaskOption2.fromOption = (option) => Task.resolve(option);
260
+ TaskOption2.fromTask = (task) => Task.map(Option.some)(task);
261
+ TaskOption2.tryCatch = (f) => Task.from(
262
+ () => f().then(Option.some).catch(() => Option.none())
263
+ );
264
+ TaskOption2.map = (f) => (data) => Task.map(Option.map(f))(data);
265
+ TaskOption2.chain = (f) => (data) => Task.chain((option) => Option.isSome(option) ? f(option.value) : Task.resolve(Option.none()))(data);
266
+ TaskOption2.ap = (arg) => (data) => Task.from(
267
+ () => Promise.all([
268
+ Deferred.toPromise(data()),
269
+ Deferred.toPromise(arg())
270
+ ]).then(([of_, oa]) => Option.ap(oa)(of_))
271
+ );
272
+ TaskOption2.fold = (onNone, onSome) => (data) => Task.map(Option.fold(onNone, onSome))(data);
273
+ TaskOption2.match = (cases) => (data) => Task.map(Option.match(cases))(data);
274
+ TaskOption2.getOrElse = (defaultValue) => (data) => Task.map(Option.getOrElse(defaultValue))(data);
275
+ TaskOption2.tap = (f) => (data) => Task.map(Option.tap(f))(data);
276
+ TaskOption2.filter = (predicate) => (data) => Task.map(Option.filter(predicate))(data);
277
+ TaskOption2.toTaskResult = (onNone) => (data) => Task.map(Option.toResult(onNone))(data);
278
+ })(TaskOption || (TaskOption = {}));
279
+
280
+ // src/Core/TaskResult.ts
281
+ var TaskResult;
282
+ ((TaskResult2) => {
283
+ TaskResult2.ok = (value) => Task.resolve(Result.ok(value));
284
+ TaskResult2.err = (error) => Task.resolve(Result.err(error));
285
+ TaskResult2.tryCatch = (f, onError) => Task.from(
286
+ () => f().then(Result.ok).catch((e) => Result.err(onError(e)))
287
+ );
288
+ TaskResult2.map = (f) => (data) => Task.map(Result.map(f))(data);
289
+ TaskResult2.mapError = (f) => (data) => Task.map(Result.mapError(f))(data);
290
+ TaskResult2.chain = (f) => (data) => Task.chain((result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.err(result.error)))(
291
+ data
292
+ );
293
+ TaskResult2.fold = (onErr, onOk) => (data) => Task.map(Result.fold(onErr, onOk))(data);
294
+ TaskResult2.match = (cases) => (data) => Task.map(Result.match(cases))(data);
295
+ TaskResult2.recover = (fallback) => (data) => Task.chain(
296
+ (result) => Result.isErr(result) ? fallback(result.error) : Task.resolve(result)
297
+ )(data);
298
+ TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
299
+ TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
300
+ TaskResult2.retry = (options) => (data) => Task.from(() => {
301
+ const { attempts, backoff, when: shouldRetry } = options;
302
+ const getDelay = (n) => backoff === void 0 ? 0 : typeof backoff === "function" ? backoff(n) : backoff;
303
+ const run = (left) => Deferred.toPromise(data()).then((result) => {
304
+ if (Result.isOk(result)) return result;
305
+ if (left <= 1) return result;
306
+ if (shouldRetry !== void 0 && !shouldRetry(result.error)) {
307
+ return result;
308
+ }
309
+ const ms = getDelay(attempts - left + 1);
310
+ return (ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve()).then(() => run(left - 1));
311
+ });
312
+ return run(attempts);
313
+ });
314
+ TaskResult2.timeout = (ms, onTimeout) => (data) => Task.from(() => {
315
+ let timerId;
316
+ return Promise.race([
317
+ Deferred.toPromise(data()).then((result) => {
318
+ clearTimeout(timerId);
319
+ return result;
320
+ }),
321
+ new Promise((resolve) => {
322
+ timerId = setTimeout(() => resolve(Result.err(onTimeout())), ms);
323
+ })
324
+ ]);
325
+ });
326
+ })(TaskResult || (TaskResult = {}));
327
+
328
+ // src/Core/Validation.ts
329
+ var Validation;
330
+ ((Validation2) => {
331
+ Validation2.valid = (value) => ({
332
+ kind: "Valid",
333
+ value
334
+ });
335
+ Validation2.invalid = (error) => ({
336
+ kind: "Invalid",
337
+ errors: [error]
338
+ });
339
+ Validation2.invalidAll = (errors) => ({
340
+ kind: "Invalid",
341
+ errors
342
+ });
343
+ Validation2.isValid = (data) => data.kind === "Valid";
344
+ Validation2.isInvalid = (data) => data.kind === "Invalid";
345
+ Validation2.map = (f) => (data) => (0, Validation2.isValid)(data) ? (0, Validation2.valid)(f(data.value)) : data;
346
+ Validation2.ap = (arg) => (data) => {
347
+ if ((0, Validation2.isValid)(data) && (0, Validation2.isValid)(arg)) return (0, Validation2.valid)(data.value(arg.value));
348
+ const errors = [
349
+ ...(0, Validation2.isInvalid)(data) ? data.errors : [],
350
+ ...(0, Validation2.isInvalid)(arg) ? arg.errors : []
351
+ ];
352
+ return (0, Validation2.invalidAll)(errors);
353
+ };
354
+ Validation2.fold = (onInvalid, onValid) => (data) => (0, Validation2.isValid)(data) ? onValid(data.value) : onInvalid(data.errors);
355
+ Validation2.match = (cases) => (data) => (0, Validation2.isValid)(data) ? cases.valid(data.value) : cases.invalid(data.errors);
356
+ Validation2.getOrElse = (defaultValue) => (data) => (0, Validation2.isValid)(data) ? data.value : defaultValue();
357
+ Validation2.tap = (f) => (data) => {
358
+ if ((0, Validation2.isValid)(data)) f(data.value);
359
+ return data;
360
+ };
361
+ Validation2.recover = (fallback) => (data) => (0, Validation2.isValid)(data) ? data : fallback(data.errors);
362
+ Validation2.recoverUnless = (blockedErrors, fallback) => (data) => (0, Validation2.isInvalid)(data) && !data.errors.some((err) => blockedErrors.includes(err)) ? fallback() : data;
363
+ Validation2.product = (first, second) => {
364
+ if ((0, Validation2.isValid)(first) && (0, Validation2.isValid)(second)) return (0, Validation2.valid)([first.value, second.value]);
365
+ const errors = [
366
+ ...(0, Validation2.isInvalid)(first) ? first.errors : [],
367
+ ...(0, Validation2.isInvalid)(second) ? second.errors : []
368
+ ];
369
+ return (0, Validation2.invalidAll)(errors);
370
+ };
371
+ Validation2.productAll = (data) => {
372
+ const values = [];
373
+ const errors = [];
374
+ for (const v of data) {
375
+ if ((0, Validation2.isValid)(v)) values.push(v.value);
376
+ else errors.push(...v.errors);
377
+ }
378
+ return errors.length > 0 ? (0, Validation2.invalidAll)(errors) : (0, Validation2.valid)(values);
379
+ };
380
+ })(Validation || (Validation = {}));
381
+
382
+ // src/Core/TaskValidation.ts
383
+ var TaskValidation;
384
+ ((TaskValidation2) => {
385
+ TaskValidation2.valid = (value) => Task.resolve(Validation.valid(value));
386
+ TaskValidation2.invalid = (error) => Task.resolve(Validation.invalid(error));
387
+ TaskValidation2.invalidAll = (errors) => Task.resolve(Validation.invalidAll(errors));
388
+ TaskValidation2.fromValidation = (validation) => Task.resolve(validation);
389
+ TaskValidation2.tryCatch = (f, onError) => Task.from(
390
+ () => f().then(Validation.valid).catch((e) => Validation.invalid(onError(e)))
391
+ );
392
+ TaskValidation2.map = (f) => (data) => Task.map(Validation.map(f))(data);
393
+ TaskValidation2.ap = (arg) => (data) => Task.from(
394
+ () => Promise.all([
395
+ Deferred.toPromise(data()),
396
+ Deferred.toPromise(arg())
397
+ ]).then(([vf, va]) => Validation.ap(va)(vf))
398
+ );
399
+ TaskValidation2.fold = (onInvalid, onValid) => (data) => Task.map(Validation.fold(onInvalid, onValid))(data);
400
+ TaskValidation2.match = (cases) => (data) => Task.map(Validation.match(cases))(data);
401
+ TaskValidation2.getOrElse = (defaultValue) => (data) => Task.map(Validation.getOrElse(defaultValue))(data);
402
+ TaskValidation2.tap = (f) => (data) => Task.map(Validation.tap(f))(data);
403
+ TaskValidation2.recover = (fallback) => (data) => Task.chain(
404
+ (validation) => Validation.isValid(validation) ? Task.resolve(validation) : fallback(validation.errors)
405
+ )(data);
406
+ TaskValidation2.product = (first, second) => Task.from(
407
+ () => Promise.all([
408
+ Deferred.toPromise(first()),
409
+ Deferred.toPromise(second())
410
+ ]).then(([va, vb]) => Validation.product(va, vb))
411
+ );
412
+ TaskValidation2.productAll = (data) => Task.from(
413
+ () => Promise.all(data.map((t) => Deferred.toPromise(t()))).then((results) => Validation.productAll(results))
414
+ );
415
+ })(TaskValidation || (TaskValidation = {}));
416
+
417
+ // src/Core/These.ts
418
+ var These;
419
+ ((These2) => {
420
+ These2.first = (value) => ({ kind: "First", first: value });
421
+ These2.second = (value) => ({ kind: "Second", second: value });
422
+ These2.both = (first2, second2) => ({
423
+ kind: "Both",
424
+ first: first2,
425
+ second: second2
426
+ });
427
+ These2.isFirst = (data) => data.kind === "First";
428
+ These2.isSecond = (data) => data.kind === "Second";
429
+ These2.isBoth = (data) => data.kind === "Both";
430
+ These2.hasFirst = (data) => data.kind === "First" || data.kind === "Both";
431
+ These2.hasSecond = (data) => data.kind === "Second" || data.kind === "Both";
432
+ These2.mapFirst = (f) => (data) => {
433
+ if ((0, These2.isSecond)(data)) return data;
434
+ if ((0, These2.isFirst)(data)) return (0, These2.first)(f(data.first));
435
+ return (0, These2.both)(f(data.first), data.second);
436
+ };
437
+ These2.mapSecond = (f) => (data) => {
438
+ if ((0, These2.isFirst)(data)) return data;
439
+ if ((0, These2.isSecond)(data)) return (0, These2.second)(f(data.second));
440
+ return (0, These2.both)(data.first, f(data.second));
441
+ };
442
+ These2.mapBoth = (onFirst, onSecond) => (data) => {
443
+ if ((0, These2.isSecond)(data)) return (0, These2.second)(onSecond(data.second));
444
+ if ((0, These2.isFirst)(data)) return (0, These2.first)(onFirst(data.first));
445
+ return (0, These2.both)(onFirst(data.first), onSecond(data.second));
446
+ };
447
+ These2.chainFirst = (f) => (data) => {
448
+ if ((0, These2.isSecond)(data)) return data;
449
+ return f(data.first);
450
+ };
451
+ These2.chainSecond = (f) => (data) => {
452
+ if ((0, These2.isFirst)(data)) return data;
453
+ return f(data.second);
454
+ };
455
+ These2.fold = (onFirst, onSecond, onBoth) => (data) => {
456
+ if ((0, These2.isSecond)(data)) return onSecond(data.second);
457
+ if ((0, These2.isFirst)(data)) return onFirst(data.first);
458
+ return onBoth(data.first, data.second);
459
+ };
460
+ These2.match = (cases) => (data) => {
461
+ if ((0, These2.isSecond)(data)) return cases.second(data.second);
462
+ if ((0, These2.isFirst)(data)) return cases.first(data.first);
463
+ return cases.both(data.first, data.second);
464
+ };
465
+ These2.getFirstOrElse = (defaultValue) => (data) => (0, These2.hasFirst)(data) ? data.first : defaultValue();
466
+ These2.getSecondOrElse = (defaultValue) => (data) => (0, These2.hasSecond)(data) ? data.second : defaultValue();
467
+ These2.tap = (f) => (data) => {
468
+ if ((0, These2.hasFirst)(data)) f(data.first);
469
+ return data;
470
+ };
471
+ These2.swap = (data) => {
472
+ if ((0, These2.isSecond)(data)) return (0, These2.first)(data.second);
473
+ if ((0, These2.isFirst)(data)) return (0, These2.second)(data.first);
474
+ return (0, These2.both)(data.second, data.first);
475
+ };
476
+ })(These || (These = {}));
477
+
478
+ // src/Core/Tuple.ts
479
+ var Tuple;
480
+ ((Tuple2) => {
481
+ Tuple2.make = (first2, second2) => [first2, second2];
482
+ Tuple2.first = (tuple) => tuple[0];
483
+ Tuple2.second = (tuple) => tuple[1];
484
+ Tuple2.mapFirst = (f) => (tuple) => [f(tuple[0]), tuple[1]];
485
+ Tuple2.mapSecond = (f) => (tuple) => [tuple[0], f(tuple[1])];
486
+ Tuple2.mapBoth = (onFirst, onSecond) => (tuple) => [
487
+ onFirst(tuple[0]),
488
+ onSecond(tuple[1])
489
+ ];
490
+ Tuple2.fold = (f) => (tuple) => f(tuple[0], tuple[1]);
491
+ Tuple2.swap = (tuple) => [tuple[1], tuple[0]];
492
+ Tuple2.toArray = (tuple) => [...tuple];
493
+ Tuple2.tap = (f) => (tuple) => {
494
+ f(tuple[0], tuple[1]);
495
+ return tuple;
496
+ };
497
+ })(Tuple || (Tuple = {}));
498
+ export {
499
+ Deferred,
500
+ Lens,
501
+ Logged,
502
+ Option,
503
+ Optional,
504
+ Predicate,
505
+ Reader,
506
+ Refinement,
507
+ RemoteData,
508
+ Result,
509
+ State,
510
+ Task,
511
+ TaskOption,
512
+ TaskResult,
513
+ TaskValidation,
514
+ These,
515
+ Tuple,
516
+ Validation
517
+ };
@@ -0,0 +1,54 @@
1
+ export { N as NonEmptyList, i as isNonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
2
+
3
+ declare const _brand: unique symbol;
4
+ /**
5
+ * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
6
+ * Prevents accidentally mixing up values that share the same underlying type.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * type UserId = Brand<"UserId", string>;
11
+ * type ProductId = Brand<"ProductId", string>;
12
+ *
13
+ * const toUserId = Brand.wrap<"UserId", string>();
14
+ * const toProductId = Brand.wrap<"ProductId", string>();
15
+ *
16
+ * const userId: UserId = toUserId("user-123");
17
+ * const productId: ProductId = toProductId("prod-456");
18
+ *
19
+ * // Type error: ProductId is not assignable to UserId
20
+ * // const wrong: UserId = productId;
21
+ * ```
22
+ */
23
+ type Brand<K extends string, T> = T & {
24
+ readonly [_brand]: K;
25
+ };
26
+ declare namespace Brand {
27
+ /**
28
+ * Returns a constructor that wraps a value of type T in brand K.
29
+ * The resulting function performs an unchecked cast — only use when the raw
30
+ * value is known to satisfy the brand's invariants.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * type PositiveNumber = Brand<"PositiveNumber", number>;
35
+ * const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
36
+ *
37
+ * const n: PositiveNumber = toPositiveNumber(42);
38
+ * ```
39
+ */
40
+ const wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
41
+ /**
42
+ * Strips the brand and returns the underlying value.
43
+ * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const userId: UserId = toUserId("user-123");
48
+ * const raw: string = Brand.unwrap(userId); // "user-123"
49
+ * ```
50
+ */
51
+ const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
52
+ }
53
+
54
+ export { Brand };
@@ -1,3 +1,5 @@
1
+ export { N as NonEmptyList, i as isNonEmptyList } from './NonEmptyList-BlGFjor5.js';
2
+
1
3
  declare const _brand: unique symbol;
2
4
  /**
3
5
  * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
@@ -18,10 +20,10 @@ declare const _brand: unique symbol;
18
20
  * // const wrong: UserId = productId;
19
21
  * ```
20
22
  */
21
- export type Brand<K extends string, T> = T & {
23
+ type Brand<K extends string, T> = T & {
22
24
  readonly [_brand]: K;
23
25
  };
24
- export declare namespace Brand {
26
+ declare namespace Brand {
25
27
  /**
26
28
  * Returns a constructor that wraps a value of type T in brand K.
27
29
  * The resulting function performs an unchecked cast — only use when the raw
@@ -48,5 +50,5 @@ export declare namespace Brand {
48
50
  */
49
51
  const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
50
52
  }
51
- export {};
52
- //# sourceMappingURL=Brand.d.ts.map
53
+
54
+ export { Brand };
package/dist/types.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/Types/index.ts
21
+ var Types_exports = {};
22
+ __export(Types_exports, {
23
+ Brand: () => Brand,
24
+ isNonEmptyList: () => isNonEmptyList
25
+ });
26
+ module.exports = __toCommonJS(Types_exports);
27
+
28
+ // src/Types/Brand.ts
29
+ var Brand;
30
+ ((Brand2) => {
31
+ Brand2.wrap = () => (value) => value;
32
+ Brand2.unwrap = (branded) => branded;
33
+ })(Brand || (Brand = {}));
34
+
35
+ // src/Types/NonEmptyList.ts
36
+ var isNonEmptyList = (list) => list.length > 0;
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ Brand,
40
+ isNonEmptyList
41
+ });
package/dist/types.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ isNonEmptyList
3
+ } from "./chunk-DBIC62UV.mjs";
4
+
5
+ // src/Types/Brand.ts
6
+ var Brand;
7
+ ((Brand2) => {
8
+ Brand2.wrap = () => (value) => value;
9
+ Brand2.unwrap = (branded) => branded;
10
+ })(Brand || (Brand = {}));
11
+ export {
12
+ Brand,
13
+ isNonEmptyList
14
+ };