@nlozgachev/pipelined 0.47.0 → 0.49.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.
- package/README.md +58 -5
- package/dist/Duration-B8joKzro.d.mts +181 -0
- package/dist/Duration-B8joKzro.d.ts +181 -0
- package/dist/{InternalTypes-Mssktd7z.d.ts → InternalTypes-CDiDBAY4.d.mts} +20 -1
- package/dist/{InternalTypes-CLE7qlOc.d.mts → InternalTypes-LdhLQx3N.d.ts} +20 -1
- package/dist/{Validation-BMsvixWH.d.ts → Validation-1OgJJdeA.d.ts} +507 -37
- package/dist/{Validation-v38R0qH-.d.mts → Validation-D-aARYlP.d.mts} +507 -37
- package/dist/{chunk-KOYYDQH4.mjs → chunk-5OFVS5UZ.mjs} +7 -2
- package/dist/{chunk-XTVF5R6R.mjs → chunk-DENXUTKL.mjs} +24 -0
- package/dist/{chunk-W2L244AS.mjs → chunk-EPT3GYGN.mjs} +279 -1
- package/dist/{chunk-VSU36S2K.mjs → chunk-IHLH2XYQ.mjs} +330 -18
- package/dist/composition.d.mts +226 -18
- package/dist/composition.d.ts +226 -18
- package/dist/composition.js +10 -3
- package/dist/composition.mjs +8 -4
- package/dist/core.d.mts +304 -9
- package/dist/core.d.ts +304 -9
- package/dist/core.js +330 -17
- package/dist/core.mjs +4 -2
- package/dist/data.d.mts +619 -41
- package/dist/data.d.ts +619 -41
- package/dist/data.js +424 -17
- package/dist/data.mjs +7 -3
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +658 -33
- package/dist/index.mjs +19 -7
- package/dist/types.d.mts +37 -108
- package/dist/types.d.ts +37 -108
- package/dist/types.js +27 -2
- package/dist/types.mjs +5 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -21,12 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Arr: () => Arr,
|
|
24
|
+
BigNum: () => BigNum,
|
|
24
25
|
Brand: () => Brand,
|
|
25
26
|
Combinable: () => Combinable,
|
|
26
27
|
Deferred: () => Deferred,
|
|
27
28
|
Dict: () => Dict,
|
|
28
29
|
Duration: () => Duration,
|
|
29
30
|
Equality: () => Equality,
|
|
31
|
+
Json: () => Json,
|
|
30
32
|
Lazy: () => Lazy,
|
|
31
33
|
Lens: () => Lens,
|
|
32
34
|
Logged: () => Logged,
|
|
@@ -42,8 +44,10 @@ __export(src_exports, {
|
|
|
42
44
|
RemoteData: () => RemoteData,
|
|
43
45
|
Resource: () => Resource,
|
|
44
46
|
Result: () => Result,
|
|
47
|
+
RetryPolicy: () => RetryPolicy,
|
|
45
48
|
State: () => State,
|
|
46
49
|
Str: () => Str,
|
|
50
|
+
Stream: () => Stream,
|
|
47
51
|
Task: () => Task,
|
|
48
52
|
TaskMaybe: () => TaskMaybe,
|
|
49
53
|
TaskResult: () => TaskResult,
|
|
@@ -77,9 +81,11 @@ __export(src_exports, {
|
|
|
77
81
|
or: () => or,
|
|
78
82
|
pipe: () => pipe,
|
|
79
83
|
tap: () => tap,
|
|
84
|
+
tuple: () => tuple,
|
|
80
85
|
uncurry: () => uncurry,
|
|
81
86
|
uncurry3: () => uncurry3,
|
|
82
|
-
uncurry4: () => uncurry4
|
|
87
|
+
uncurry4: () => uncurry4,
|
|
88
|
+
untuple: () => untuple
|
|
83
89
|
});
|
|
84
90
|
module.exports = __toCommonJS(src_exports);
|
|
85
91
|
|
|
@@ -281,6 +287,8 @@ var once = (f) => {
|
|
|
281
287
|
};
|
|
282
288
|
};
|
|
283
289
|
var defaultTo = (fallback) => (a) => a === null || a === void 0 ? fallback : a;
|
|
290
|
+
var tuple = (f) => (args) => f(...args);
|
|
291
|
+
var untuple = (f) => (...args) => f(args);
|
|
284
292
|
|
|
285
293
|
// src/Composition/juxt.ts
|
|
286
294
|
function juxt(fns) {
|
|
@@ -288,8 +296,9 @@ function juxt(fns) {
|
|
|
288
296
|
}
|
|
289
297
|
|
|
290
298
|
// src/Composition/memoize.ts
|
|
291
|
-
var memoize = (f,
|
|
299
|
+
var memoize = (f, options) => {
|
|
292
300
|
const cache = /* @__PURE__ */ new Map();
|
|
301
|
+
const keyFn = options?.key ?? ((a) => a);
|
|
293
302
|
return (a) => {
|
|
294
303
|
const key = keyFn(a);
|
|
295
304
|
if (cache.has(key)) {
|
|
@@ -410,6 +419,29 @@ var Brand;
|
|
|
410
419
|
Brand2.unwrap = (branded) => branded;
|
|
411
420
|
})(Brand || (Brand = {}));
|
|
412
421
|
|
|
422
|
+
// src/Types/RetryPolicy.ts
|
|
423
|
+
var RetryPolicy;
|
|
424
|
+
((RetryPolicy2) => {
|
|
425
|
+
RetryPolicy2.constant = (options) => ({
|
|
426
|
+
attempts: Math.max(1, options.attempts),
|
|
427
|
+
getDelay: () => options.delay
|
|
428
|
+
});
|
|
429
|
+
RetryPolicy2.exponential = (options) => {
|
|
430
|
+
const attempts = Math.max(1, options.attempts);
|
|
431
|
+
const initialMs = Duration.to.milliseconds(options.initial);
|
|
432
|
+
const factor = options.factor ?? 2;
|
|
433
|
+
const jitter = options.jitter ?? false;
|
|
434
|
+
return {
|
|
435
|
+
attempts,
|
|
436
|
+
getDelay: (attempt) => {
|
|
437
|
+
const rawMs = initialMs * factor ** Math.max(0, attempt - 1);
|
|
438
|
+
const finalMs = jitter ? Math.random() * rawMs : rawMs;
|
|
439
|
+
return Duration.milliseconds(finalMs);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
})(RetryPolicy || (RetryPolicy = {}));
|
|
444
|
+
|
|
413
445
|
// src/Types/Duration.ts
|
|
414
446
|
var Duration;
|
|
415
447
|
((Duration2) => {
|
|
@@ -540,6 +572,26 @@ var Combinable;
|
|
|
540
572
|
combine: (b) => (a) => Maybe.is.none(a) ? b : Maybe.is.none(b) ? a : Maybe.make.some(inner.combine(b.value)(a.value))
|
|
541
573
|
});
|
|
542
574
|
Combinable2.fold = (c) => (data) => data.reduce((acc, x) => c.combine(x)(acc), c.empty);
|
|
575
|
+
Combinable2.struct = (fields) => {
|
|
576
|
+
const empty = {};
|
|
577
|
+
for (const key in fields) {
|
|
578
|
+
if (Object.hasOwn(fields, key)) {
|
|
579
|
+
empty[key] = fields[key].empty;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return {
|
|
583
|
+
empty,
|
|
584
|
+
combine: (b) => (a) => {
|
|
585
|
+
const result = {};
|
|
586
|
+
for (const key in fields) {
|
|
587
|
+
if (Object.hasOwn(fields, key)) {
|
|
588
|
+
result[key] = fields[key].combine(b[key])(a[key]);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
};
|
|
543
595
|
})(Combinable || (Combinable = {}));
|
|
544
596
|
|
|
545
597
|
// src/Core/Deferred.ts
|
|
@@ -556,6 +608,8 @@ var Deferred;
|
|
|
556
608
|
((to2) => {
|
|
557
609
|
to2.Promise = (d) => new globalThis.Promise((resolve) => d.then(resolve));
|
|
558
610
|
})(to = Deferred2.to || (Deferred2.to = {}));
|
|
611
|
+
Deferred2.all = (deferreds) => from.Promise(globalThis.Promise.all(deferreds.map((d) => to.Promise(d))));
|
|
612
|
+
Deferred2.race = (deferreds) => from.Promise(globalThis.Promise.race(deferreds.map((d) => to.Promise(d))));
|
|
559
613
|
})(Deferred || (Deferred = {}));
|
|
560
614
|
|
|
561
615
|
// src/Core/Equality.ts
|
|
@@ -568,6 +622,27 @@ var Equality;
|
|
|
568
622
|
Equality3.array = (eq) => (a, b) => a.length === b.length && a.every((x, i) => eq(x, b[i]));
|
|
569
623
|
Equality3.by = (f) => (eq) => (a, b) => eq(f(a), f(b));
|
|
570
624
|
Equality3.and = (eq2) => (eq1) => (a, b) => eq1(a, b) && eq2(a, b);
|
|
625
|
+
Equality3.struct = (fields) => (a, b) => {
|
|
626
|
+
for (const key in fields) {
|
|
627
|
+
if (Object.hasOwn(fields, key)) {
|
|
628
|
+
if (!fields[key](a[key], b[key])) {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return true;
|
|
634
|
+
};
|
|
635
|
+
Equality3.tuple = (...equalities) => (a, b) => {
|
|
636
|
+
if (a.length !== b.length) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
for (let i = 0; i < equalities.length; i++) {
|
|
640
|
+
if (!equalities[i](a[i], b[i])) {
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return true;
|
|
645
|
+
};
|
|
571
646
|
})(Equality || (Equality = {}));
|
|
572
647
|
|
|
573
648
|
// src/Core/Lazy.ts
|
|
@@ -647,6 +722,10 @@ var Logged;
|
|
|
647
722
|
Logged2.bind = (key, f) => (data) => (0, Logged2.chain)(
|
|
648
723
|
(a) => (0, Logged2.map)((b) => ({ ...a, [key]: b }))(f(a))
|
|
649
724
|
)(data);
|
|
725
|
+
Logged2.focus = (lens) => (f) => (data) => ({
|
|
726
|
+
value: lens.set(f(lens.get(data.value)))(data.value),
|
|
727
|
+
log: data.log
|
|
728
|
+
});
|
|
650
729
|
})(Logged || (Logged = {}));
|
|
651
730
|
|
|
652
731
|
// src/Core/Maybe.ts
|
|
@@ -706,6 +785,7 @@ var Maybe;
|
|
|
706
785
|
}
|
|
707
786
|
return make.some(result);
|
|
708
787
|
};
|
|
788
|
+
Maybe3.transposeResult = (data) => is.none(data) ? Result.make.ok(make.none()) : Result.is.ok(data.value) ? Result.make.ok(make.some(data.value.value)) : Result.make.err(data.value.error);
|
|
709
789
|
})(Maybe || (Maybe = {}));
|
|
710
790
|
|
|
711
791
|
// src/internal/Op.util.ts
|
|
@@ -1857,6 +1937,25 @@ var Ordering;
|
|
|
1857
1937
|
return r !== 0 ? r : ord2(a, b);
|
|
1858
1938
|
};
|
|
1859
1939
|
Ordering3.by = (f) => (ord) => (a, b) => ord(f(a), f(b));
|
|
1940
|
+
Ordering3.byFields = (orderings) => (a, b) => {
|
|
1941
|
+
for (let i = 0; i < orderings.length; i++) {
|
|
1942
|
+
const res = orderings[i](a, b);
|
|
1943
|
+
if (res !== 0) {
|
|
1944
|
+
return res;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
return 0;
|
|
1948
|
+
};
|
|
1949
|
+
Ordering3.tuple = (...orderings) => (a, b) => {
|
|
1950
|
+
const len = Math.min(a.length, b.length);
|
|
1951
|
+
for (let i = 0; i < len; i++) {
|
|
1952
|
+
const res = orderings[i](a[i], b[i]);
|
|
1953
|
+
if (res !== 0) {
|
|
1954
|
+
return res;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
return a.length - b.length;
|
|
1958
|
+
};
|
|
1860
1959
|
})(Ordering || (Ordering = {}));
|
|
1861
1960
|
|
|
1862
1961
|
// src/Core/Predicate.ts
|
|
@@ -1872,6 +1971,15 @@ var Predicate;
|
|
|
1872
1971
|
((from2) => {
|
|
1873
1972
|
from2.Refinement = (r) => r;
|
|
1874
1973
|
})(from = Predicate2.from || (Predicate2.from = {}));
|
|
1974
|
+
Predicate2.match = (branches, fallback) => (a) => {
|
|
1975
|
+
for (let i = 0; i < branches.length; i++) {
|
|
1976
|
+
const [p, h] = branches[i];
|
|
1977
|
+
if (p(a)) {
|
|
1978
|
+
return h(a);
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
return fallback(a);
|
|
1982
|
+
};
|
|
1875
1983
|
})(Predicate || (Predicate = {}));
|
|
1876
1984
|
|
|
1877
1985
|
// src/Core/Reader.ts
|
|
@@ -2071,11 +2179,11 @@ var Result;
|
|
|
2071
2179
|
is2.ok = (data) => data.kind === "Ok";
|
|
2072
2180
|
is2.err = (data) => data.kind === "Err";
|
|
2073
2181
|
})(is = Result4.is || (Result4.is = {}));
|
|
2074
|
-
Result4.tryCatch = (f,
|
|
2182
|
+
Result4.tryCatch = (f, options) => {
|
|
2075
2183
|
try {
|
|
2076
2184
|
return make.ok(f());
|
|
2077
2185
|
} catch (error) {
|
|
2078
|
-
return make.err(onError(error));
|
|
2186
|
+
return make.err(options.onError(error));
|
|
2079
2187
|
}
|
|
2080
2188
|
};
|
|
2081
2189
|
Result4.map = (f) => (data) => is.ok(data) ? make.ok(f(data.value)) : data;
|
|
@@ -2101,20 +2209,23 @@ var Result;
|
|
|
2101
2209
|
from2.Predicate = (pred, onFalse) => (a) => pred(a) ? make.ok(a) : make.err(onFalse(a));
|
|
2102
2210
|
from2.nullable = (onNull) => (value) => value === null || value === void 0 ? make.err(onNull()) : make.ok(value);
|
|
2103
2211
|
from2.Maybe = (onNone) => (maybe) => Maybe.is.none(maybe) ? make.err(onNone()) : make.ok(maybe.value);
|
|
2104
|
-
from2.throwable = (f,
|
|
2212
|
+
from2.throwable = (f, options) => (...args) => {
|
|
2105
2213
|
try {
|
|
2106
2214
|
return make.ok(f(...args));
|
|
2107
2215
|
} catch (error) {
|
|
2108
|
-
return make.err(onError(error));
|
|
2216
|
+
return make.err(options.onError(error));
|
|
2109
2217
|
}
|
|
2110
2218
|
};
|
|
2219
|
+
from2.Validation = (combineErrors) => (val) => Validation.is.passed(val) ? make.ok(val.value) : make.err(combineErrors(val.errors));
|
|
2111
2220
|
})(from = Result4.from || (Result4.from = {}));
|
|
2112
2221
|
Result4.recover = (fallback) => (data) => is.ok(data) ? data : fallback(data.error);
|
|
2113
2222
|
Result4.recoverUnless = (isBlocked, fallback) => (data) => is.err(data) && !isBlocked(data.error) ? fallback() : data;
|
|
2114
2223
|
let to;
|
|
2115
2224
|
((to2) => {
|
|
2116
2225
|
to2.Maybe = (data) => is.ok(data) ? Maybe.make.some(data.value) : Maybe.make.none();
|
|
2226
|
+
to2.Validation = (data) => Validation.from.Result(data);
|
|
2117
2227
|
})(to = Result4.to || (Result4.to = {}));
|
|
2228
|
+
Result4.transposeMaybe = (data) => is.err(data) ? Maybe.make.some(data) : Maybe.is.some(data.value) ? Maybe.make.some(make.ok(data.value.value)) : Maybe.make.none();
|
|
2118
2229
|
Result4.ap = (arg) => (data) => is.ok(data) && is.ok(arg) ? make.ok(data.value(arg.value)) : is.err(data) ? data : arg;
|
|
2119
2230
|
Result4.bindTo = (key) => (data) => (0, Result4.map)((a) => ({ [key]: a }))(data);
|
|
2120
2231
|
Result4.bind = (key, f) => (data) => (0, Result4.chain)(
|
|
@@ -2133,6 +2244,8 @@ var Result;
|
|
|
2133
2244
|
}
|
|
2134
2245
|
return make.ok(result);
|
|
2135
2246
|
};
|
|
2247
|
+
Result4.ensure = (predicate, onFail) => (data) => is.err(data) ? data : predicate(data.value) ? data : make.err(onFail(data.value));
|
|
2248
|
+
Result4.bimap = (onErr, onOk) => (data) => is.ok(data) ? make.ok(onOk(data.value)) : make.err(onErr(data.error));
|
|
2136
2249
|
})(Result || (Result = {}));
|
|
2137
2250
|
|
|
2138
2251
|
// src/Core/State.ts
|
|
@@ -2168,13 +2281,129 @@ var State;
|
|
|
2168
2281
|
State2.bind = (key, f) => (data) => (0, State2.chain)(
|
|
2169
2282
|
(a) => (0, State2.map)((b) => ({ ...a, [key]: b }))(f(a))
|
|
2170
2283
|
)(data);
|
|
2284
|
+
State2.focus = (lens) => (stateOp) => (s) => {
|
|
2285
|
+
const subState = lens.get(s);
|
|
2286
|
+
const [b, newSubState] = stateOp(subState);
|
|
2287
|
+
return [b, lens.set(newSubState)(s)];
|
|
2288
|
+
};
|
|
2171
2289
|
})(State || (State = {}));
|
|
2172
2290
|
|
|
2291
|
+
// src/Core/Stream.ts
|
|
2292
|
+
var Stream;
|
|
2293
|
+
((Stream2) => {
|
|
2294
|
+
Stream2.make = (options) => ({
|
|
2295
|
+
options,
|
|
2296
|
+
_listeners: /* @__PURE__ */ new Set()
|
|
2297
|
+
});
|
|
2298
|
+
Stream2.emit = (target, message) => {
|
|
2299
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
2300
|
+
const msg = message;
|
|
2301
|
+
for (const stream of targets) {
|
|
2302
|
+
const listeners = Array.from(stream._listeners);
|
|
2303
|
+
for (const listener of listeners) {
|
|
2304
|
+
try {
|
|
2305
|
+
listener(msg);
|
|
2306
|
+
} catch (err2) {
|
|
2307
|
+
if (stream.options?.onError) {
|
|
2308
|
+
stream.options.onError(err2);
|
|
2309
|
+
} else {
|
|
2310
|
+
throw err2;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
Stream2.forward = (options) => {
|
|
2317
|
+
const targets = Array.isArray(options.to) ? options.to : [options.to];
|
|
2318
|
+
const filterSet = options.only ? new Set(options.only) : null;
|
|
2319
|
+
const handler = (msg) => {
|
|
2320
|
+
if (filterSet !== null && !filterSet.has(msg.kind)) {
|
|
2321
|
+
return;
|
|
2322
|
+
}
|
|
2323
|
+
for (const target of targets) {
|
|
2324
|
+
(0, Stream2.emit)(target, msg);
|
|
2325
|
+
}
|
|
2326
|
+
};
|
|
2327
|
+
options.from._listeners.add(handler);
|
|
2328
|
+
return () => {
|
|
2329
|
+
options.from._listeners.delete(handler);
|
|
2330
|
+
};
|
|
2331
|
+
};
|
|
2332
|
+
Stream2.listen = (stream, events, options) => {
|
|
2333
|
+
const eventList = Array.isArray(events) ? events : [events];
|
|
2334
|
+
const isOrdered = options?.ordered ?? false;
|
|
2335
|
+
const isStrict = options?.strict ?? false;
|
|
2336
|
+
const isOnce = options?.once ?? false;
|
|
2337
|
+
const resetKinds = options?.reset ? new Set(Array.isArray(options.reset) ? options.reset : [options.reset]) : null;
|
|
2338
|
+
const createMatcher = (onMatch) => {
|
|
2339
|
+
let sequenceIndex = 0;
|
|
2340
|
+
return (msg) => {
|
|
2341
|
+
if (resetKinds !== null && resetKinds.has(msg.kind)) {
|
|
2342
|
+
sequenceIndex = 0;
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
if (!isOrdered) {
|
|
2346
|
+
if (eventList.includes(msg.kind)) {
|
|
2347
|
+
onMatch(msg);
|
|
2348
|
+
}
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
const expectedKind = eventList[sequenceIndex];
|
|
2352
|
+
if (msg.kind === expectedKind) {
|
|
2353
|
+
sequenceIndex++;
|
|
2354
|
+
if (sequenceIndex === eventList.length) {
|
|
2355
|
+
sequenceIndex = 0;
|
|
2356
|
+
onMatch(msg);
|
|
2357
|
+
}
|
|
2358
|
+
} else if (isStrict) {
|
|
2359
|
+
sequenceIndex = msg.kind === eventList[0] ? 1 : 0;
|
|
2360
|
+
} else if (eventList.includes(msg.kind)) {
|
|
2361
|
+
sequenceIndex = msg.kind === eventList[0] ? 1 : 0;
|
|
2362
|
+
}
|
|
2363
|
+
};
|
|
2364
|
+
};
|
|
2365
|
+
return {
|
|
2366
|
+
reduce: (reducer, initialState) => {
|
|
2367
|
+
let currentState = initialState;
|
|
2368
|
+
const listenerFn = createMatcher((msg) => {
|
|
2369
|
+
currentState = reducer(msg, currentState);
|
|
2370
|
+
if (isOnce) {
|
|
2371
|
+
stream._listeners.delete(listenerFn);
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
const unsubscribe = () => {
|
|
2375
|
+
stream._listeners.delete(listenerFn);
|
|
2376
|
+
};
|
|
2377
|
+
stream._listeners.add(listenerFn);
|
|
2378
|
+
return { unsubscribe, getState: () => currentState };
|
|
2379
|
+
},
|
|
2380
|
+
tap: (effect) => {
|
|
2381
|
+
const listenerFn = createMatcher((msg) => {
|
|
2382
|
+
effect(msg);
|
|
2383
|
+
if (isOnce) {
|
|
2384
|
+
stream._listeners.delete(listenerFn);
|
|
2385
|
+
}
|
|
2386
|
+
});
|
|
2387
|
+
const unsubscribe = () => {
|
|
2388
|
+
stream._listeners.delete(listenerFn);
|
|
2389
|
+
};
|
|
2390
|
+
stream._listeners.add(listenerFn);
|
|
2391
|
+
return unsubscribe;
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
};
|
|
2395
|
+
})(Stream || (Stream = {}));
|
|
2396
|
+
|
|
2173
2397
|
// src/Core/TaskMaybe.ts
|
|
2174
2398
|
var TaskMaybe;
|
|
2175
2399
|
((TaskMaybe2) => {
|
|
2176
|
-
|
|
2177
|
-
|
|
2400
|
+
let make;
|
|
2401
|
+
((make2) => {
|
|
2402
|
+
make2.some = (value) => Task.resolve(Maybe.make.some(value));
|
|
2403
|
+
make2.none = () => Task.resolve(Maybe.make.none());
|
|
2404
|
+
})(make = TaskMaybe2.make || (TaskMaybe2.make = {}));
|
|
2405
|
+
({ some: TaskMaybe2.some } = make);
|
|
2406
|
+
({ none: TaskMaybe2.none } = make);
|
|
2178
2407
|
let from;
|
|
2179
2408
|
((from2) => {
|
|
2180
2409
|
from2.Maybe = (option) => Task.resolve(option);
|
|
@@ -2230,19 +2459,28 @@ var TaskMaybe;
|
|
|
2230
2459
|
// src/Core/TaskResult.ts
|
|
2231
2460
|
var TaskResult;
|
|
2232
2461
|
((TaskResult2) => {
|
|
2233
|
-
|
|
2234
|
-
|
|
2462
|
+
let make;
|
|
2463
|
+
((make2) => {
|
|
2464
|
+
make2.ok = (value) => Task.resolve(Result.make.ok(value));
|
|
2465
|
+
make2.err = (error) => Task.resolve(Result.make.err(error));
|
|
2466
|
+
})(make = TaskResult2.make || (TaskResult2.make = {}));
|
|
2467
|
+
({ ok: TaskResult2.ok } = make);
|
|
2468
|
+
({ err: TaskResult2.err } = make);
|
|
2235
2469
|
let from;
|
|
2236
2470
|
((from2) => {
|
|
2237
2471
|
from2.nullable = (onNull) => (value) => Task.resolve(value === null || value === void 0 ? Result.make.err(onNull()) : Result.make.ok(value));
|
|
2238
2472
|
from2.Maybe = (onNone) => (maybe) => Task.resolve(Maybe.is.none(maybe) ? Result.make.err(onNone()) : Result.make.ok(maybe.value));
|
|
2239
2473
|
from2.Result = (result) => Task.resolve(result);
|
|
2240
|
-
from2.throwable = (f,
|
|
2241
|
-
() => f(...args).then(Result.make.ok).catch((error) => Result.make.err(onError(error)))
|
|
2474
|
+
from2.throwable = (f, options) => (...args) => Task.from.Promise(
|
|
2475
|
+
() => f(...args).then(Result.make.ok).catch((error) => Result.make.err(options.onError(error)))
|
|
2242
2476
|
);
|
|
2243
2477
|
})(from = TaskResult2.from || (TaskResult2.from = {}));
|
|
2244
|
-
|
|
2245
|
-
|
|
2478
|
+
let to;
|
|
2479
|
+
((to2) => {
|
|
2480
|
+
to2.Maybe = (data) => Task.map(Result.to.Maybe)(data);
|
|
2481
|
+
})(to = TaskResult2.to || (TaskResult2.to = {}));
|
|
2482
|
+
TaskResult2.tryCatch = (f, options) => Task.from.Promise(
|
|
2483
|
+
(signal) => Promise.resolve(f(signal)).then(Result.make.ok).catch((error) => Result.make.err(options.onError(error)))
|
|
2246
2484
|
);
|
|
2247
2485
|
TaskResult2.map = (f) => (data) => Task.map(Result.map(f))(data);
|
|
2248
2486
|
TaskResult2.mapError = (f) => (data) => Task.map(Result.mapError(f))(data);
|
|
@@ -2282,6 +2520,60 @@ var TaskResult;
|
|
|
2282
2520
|
return Result.make.ok(record);
|
|
2283
2521
|
});
|
|
2284
2522
|
});
|
|
2523
|
+
TaskResult2.retry = (policy) => (task) => Task.from.Promise((signal) => {
|
|
2524
|
+
const { attempts } = policy;
|
|
2525
|
+
const wait = (duration) => new Promise((res) => {
|
|
2526
|
+
let timerId;
|
|
2527
|
+
const onAbort = () => {
|
|
2528
|
+
clearTimeout(timerId);
|
|
2529
|
+
res();
|
|
2530
|
+
};
|
|
2531
|
+
if (signal) {
|
|
2532
|
+
if (signal.aborted) {
|
|
2533
|
+
return res();
|
|
2534
|
+
}
|
|
2535
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
2536
|
+
}
|
|
2537
|
+
timerId = setTimeout(() => {
|
|
2538
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2539
|
+
res();
|
|
2540
|
+
}, Duration.to.milliseconds(duration));
|
|
2541
|
+
});
|
|
2542
|
+
const executeAttempt = (attempt) => Deferred.to.Promise(task(signal)).then((res) => {
|
|
2543
|
+
if (Result.is.ok(res) || attempt >= attempts || signal?.aborted) {
|
|
2544
|
+
return res;
|
|
2545
|
+
}
|
|
2546
|
+
const delay = policy.getDelay(attempt);
|
|
2547
|
+
return wait(delay).then(() => executeAttempt(attempt + 1));
|
|
2548
|
+
});
|
|
2549
|
+
return executeAttempt(1);
|
|
2550
|
+
});
|
|
2551
|
+
TaskResult2.memoize = (task) => Task.memoize(task);
|
|
2552
|
+
TaskResult2.timeout = (options) => (task) => Task.from.Promise((signal) => {
|
|
2553
|
+
const ms = Duration.to.milliseconds(options.duration);
|
|
2554
|
+
return new Promise((resolve) => {
|
|
2555
|
+
let timerId;
|
|
2556
|
+
const onAbort = () => {
|
|
2557
|
+
clearTimeout(timerId);
|
|
2558
|
+
};
|
|
2559
|
+
if (signal) {
|
|
2560
|
+
if (signal.aborted) {
|
|
2561
|
+
return Deferred.to.Promise(task(signal)).then(resolve);
|
|
2562
|
+
}
|
|
2563
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
2564
|
+
}
|
|
2565
|
+
timerId = setTimeout(() => {
|
|
2566
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2567
|
+
resolve(Result.make.err(options.onTimeout()));
|
|
2568
|
+
}, ms);
|
|
2569
|
+
Deferred.to.Promise(task(signal)).then((res) => {
|
|
2570
|
+
clearTimeout(timerId);
|
|
2571
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2572
|
+
resolve(res);
|
|
2573
|
+
});
|
|
2574
|
+
});
|
|
2575
|
+
});
|
|
2576
|
+
TaskResult2.allSettled = (tasks) => Task.from.Promise((signal) => Promise.all(tasks.map((task) => Deferred.to.Promise(task(signal)))));
|
|
2285
2577
|
})(TaskResult || (TaskResult = {}));
|
|
2286
2578
|
|
|
2287
2579
|
// src/internal/InternalTypes.ts
|
|
@@ -2290,9 +2582,15 @@ var isNonEmptyArr = (list) => list.length > 0;
|
|
|
2290
2582
|
// src/Core/TaskValidation.ts
|
|
2291
2583
|
var TaskValidation;
|
|
2292
2584
|
((TaskValidation2) => {
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2585
|
+
let make;
|
|
2586
|
+
((make2) => {
|
|
2587
|
+
make2.passed = (value) => Task.resolve(Validation.make.passed(value));
|
|
2588
|
+
make2.failed = (error) => Task.resolve(Validation.make.failed(error));
|
|
2589
|
+
make2.failedAll = (errors) => Task.resolve(Validation.make.failedAll(errors));
|
|
2590
|
+
})(make = TaskValidation2.make || (TaskValidation2.make = {}));
|
|
2591
|
+
({ passed: TaskValidation2.passed } = make);
|
|
2592
|
+
({ failed: TaskValidation2.failed } = make);
|
|
2593
|
+
({ failedAll: TaskValidation2.failedAll } = make);
|
|
2296
2594
|
let from;
|
|
2297
2595
|
((from2) => {
|
|
2298
2596
|
from2.Validation = (validation) => Task.resolve(validation);
|
|
@@ -2510,7 +2808,8 @@ var Task;
|
|
|
2510
2808
|
}
|
|
2511
2809
|
return results;
|
|
2512
2810
|
});
|
|
2513
|
-
Task2.timeout = (
|
|
2811
|
+
Task2.timeout = (options) => (task) => from.Promise((outerSignal) => {
|
|
2812
|
+
const { duration, onTimeout } = options;
|
|
2514
2813
|
const controller = new AbortController();
|
|
2515
2814
|
let timerId;
|
|
2516
2815
|
let cleanUp = () => {
|
|
@@ -2567,6 +2866,30 @@ var Task;
|
|
|
2567
2866
|
Task2.bind = (key, f) => (data) => (0, Task2.chain)(
|
|
2568
2867
|
(a) => (0, Task2.map)((b) => ({ ...a, [key]: b }))(f(a))
|
|
2569
2868
|
)(data);
|
|
2869
|
+
Task2.memoize = (task) => {
|
|
2870
|
+
let cached = null;
|
|
2871
|
+
return (signal) => {
|
|
2872
|
+
if (cached === null) {
|
|
2873
|
+
cached = task(signal);
|
|
2874
|
+
}
|
|
2875
|
+
return cached;
|
|
2876
|
+
};
|
|
2877
|
+
};
|
|
2878
|
+
Task2.withProgress = (onProgress) => (task) => (signal) => {
|
|
2879
|
+
onProgress(0);
|
|
2880
|
+
const d = task(signal);
|
|
2881
|
+
return Deferred.from.Promise(
|
|
2882
|
+
Deferred.to.Promise(d).then((res) => {
|
|
2883
|
+
onProgress(1);
|
|
2884
|
+
return res;
|
|
2885
|
+
})
|
|
2886
|
+
);
|
|
2887
|
+
};
|
|
2888
|
+
Task2.withLabel = (label) => (task) => {
|
|
2889
|
+
const fn = ((signal) => task(signal));
|
|
2890
|
+
Object.defineProperty(fn, "label", { value: label, writable: false, enumerable: true, configurable: true });
|
|
2891
|
+
return fn;
|
|
2892
|
+
};
|
|
2570
2893
|
Task2.Maybe = TaskMaybe;
|
|
2571
2894
|
Task2.Result = TaskResult;
|
|
2572
2895
|
Task2.Validation = TaskValidation;
|
|
@@ -2673,23 +2996,23 @@ var Tuple;
|
|
|
2673
2996
|
from2.pair = (first2, second2) => [first2, second2];
|
|
2674
2997
|
from2.array = (arr) => arr;
|
|
2675
2998
|
})(from = Tuple2.from || (Tuple2.from = {}));
|
|
2676
|
-
Tuple2.first = (
|
|
2677
|
-
Tuple2.second = (
|
|
2678
|
-
Tuple2.mapFirst = (f) => (
|
|
2679
|
-
Tuple2.mapSecond = (f) => (
|
|
2680
|
-
Tuple2.mapBoth = (onFirst, onSecond) => (
|
|
2681
|
-
onFirst(
|
|
2682
|
-
onSecond(
|
|
2999
|
+
Tuple2.first = (tuple2) => tuple2[0];
|
|
3000
|
+
Tuple2.second = (tuple2) => tuple2[1];
|
|
3001
|
+
Tuple2.mapFirst = (f) => (tuple2) => [f(tuple2[0]), tuple2[1]];
|
|
3002
|
+
Tuple2.mapSecond = (f) => (tuple2) => [tuple2[0], f(tuple2[1])];
|
|
3003
|
+
Tuple2.mapBoth = (onFirst, onSecond) => (tuple2) => [
|
|
3004
|
+
onFirst(tuple2[0]),
|
|
3005
|
+
onSecond(tuple2[1])
|
|
2683
3006
|
];
|
|
2684
|
-
Tuple2.fold = (f) => (
|
|
2685
|
-
Tuple2.swap = (
|
|
3007
|
+
Tuple2.fold = (f) => (tuple2) => f(tuple2[0], tuple2[1]);
|
|
3008
|
+
Tuple2.swap = (tuple2) => [tuple2[1], tuple2[0]];
|
|
2686
3009
|
let to;
|
|
2687
3010
|
((to2) => {
|
|
2688
|
-
to2.Array = (
|
|
3011
|
+
to2.Array = (tuple2) => [...tuple2];
|
|
2689
3012
|
})(to = Tuple2.to || (Tuple2.to = {}));
|
|
2690
|
-
Tuple2.tap = (f) => (
|
|
2691
|
-
f(
|
|
2692
|
-
return
|
|
3013
|
+
Tuple2.tap = (f) => (tuple2) => {
|
|
3014
|
+
f(tuple2[0], tuple2[1]);
|
|
3015
|
+
return tuple2;
|
|
2693
3016
|
};
|
|
2694
3017
|
})(Tuple || (Tuple = {}));
|
|
2695
3018
|
|
|
@@ -2707,6 +3030,13 @@ var Validation;
|
|
|
2707
3030
|
is2.passed = (data) => data.kind === "Passed";
|
|
2708
3031
|
is2.failed = (data) => data.kind === "Failed";
|
|
2709
3032
|
})(is = Validation2.is || (Validation2.is = {}));
|
|
3033
|
+
Validation2.tryCatch = (f, options) => {
|
|
3034
|
+
try {
|
|
3035
|
+
return make.passed(f());
|
|
3036
|
+
} catch (error) {
|
|
3037
|
+
return make.failed(options.onError(error));
|
|
3038
|
+
}
|
|
3039
|
+
};
|
|
2710
3040
|
let from;
|
|
2711
3041
|
((from2) => {
|
|
2712
3042
|
from2.Predicate = (pred, onFalse) => (a) => pred(a) ? make.passed(a) : make.failed(onFalse(a));
|
|
@@ -2722,6 +3052,12 @@ var Validation;
|
|
|
2722
3052
|
}
|
|
2723
3053
|
return is.passed(arg) ? make.failedAll(data.errors) : make.failedAll([...data.errors, ...arg.errors]);
|
|
2724
3054
|
};
|
|
3055
|
+
Validation2.apCustom = (concat) => (arg) => (data) => {
|
|
3056
|
+
if (is.passed(data)) {
|
|
3057
|
+
return is.passed(arg) ? make.passed(data.value(arg.value)) : make.failedAll(arg.errors);
|
|
3058
|
+
}
|
|
3059
|
+
return is.passed(arg) ? make.failedAll(data.errors) : make.failedAll(concat(data.errors, arg.errors));
|
|
3060
|
+
};
|
|
2725
3061
|
Validation2.fold = (onFailed, onPassed) => (data) => is.passed(data) ? onPassed(data.value) : onFailed(data.errors);
|
|
2726
3062
|
Validation2.match = (cases) => (data) => is.passed(data) ? cases.passed(data.value) : cases.failed(data.errors);
|
|
2727
3063
|
Validation2.getOrElse = (defaultValue) => (data) => is.passed(data) ? data.value : defaultValue();
|
|
@@ -2741,7 +3077,14 @@ var Validation;
|
|
|
2741
3077
|
Validation2.recoverUnless = (isBlocked, fallback) => (data) => is.failed(data) && !data.errors.some(isBlocked) ? fallback() : data;
|
|
2742
3078
|
let to;
|
|
2743
3079
|
((to2) => {
|
|
2744
|
-
|
|
3080
|
+
function Result4(arg) {
|
|
3081
|
+
if (typeof arg === "function") {
|
|
3082
|
+
const combine = arg;
|
|
3083
|
+
return (val) => is.passed(val) ? Result.make.ok(val.value) : Result.make.err(combine(val.errors));
|
|
3084
|
+
}
|
|
3085
|
+
return is.passed(arg) ? Result.make.ok(arg.value) : Result.make.err(arg.errors);
|
|
3086
|
+
}
|
|
3087
|
+
to2.Result = Result4;
|
|
2745
3088
|
to2.Maybe = (data) => is.passed(data) ? Maybe.make.some(data.value) : Maybe.make.none();
|
|
2746
3089
|
})(to = Validation2.to || (Validation2.to = {}));
|
|
2747
3090
|
Validation2.product = (first, second) => {
|
|
@@ -3164,9 +3507,154 @@ var Arr;
|
|
|
3164
3507
|
const i = Math.max(0, index);
|
|
3165
3508
|
return [data.slice(0, i), data.slice(i)];
|
|
3166
3509
|
};
|
|
3510
|
+
Arr2.partitionMaybe = (f) => (data) => {
|
|
3511
|
+
const failures = [];
|
|
3512
|
+
const successes = [];
|
|
3513
|
+
for (let i = 0; i < data.length; i++) {
|
|
3514
|
+
const res = f(data[i]);
|
|
3515
|
+
if (res.kind === "Some") {
|
|
3516
|
+
successes.push(res.value);
|
|
3517
|
+
} else {
|
|
3518
|
+
failures.push(data[i]);
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
return [failures, successes];
|
|
3522
|
+
};
|
|
3523
|
+
Arr2.at = (index) => (data) => {
|
|
3524
|
+
const targetIndex = index < 0 ? data.length + index : index;
|
|
3525
|
+
if (targetIndex < 0 || targetIndex >= data.length) {
|
|
3526
|
+
return Maybe.make.none();
|
|
3527
|
+
}
|
|
3528
|
+
return Maybe.make.some(data[targetIndex]);
|
|
3529
|
+
};
|
|
3530
|
+
Arr2.findMap = (f) => (data) => {
|
|
3531
|
+
for (let i = 0; i < data.length; i++) {
|
|
3532
|
+
const res = f(data[i]);
|
|
3533
|
+
if (res.kind === "Some") {
|
|
3534
|
+
return res;
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
return Maybe.make.none();
|
|
3538
|
+
};
|
|
3539
|
+
Arr2.indexBy = (keyFn) => (data) => {
|
|
3540
|
+
const map2 = new globalThis.Map();
|
|
3541
|
+
for (let i = 0; i < data.length; i++) {
|
|
3542
|
+
map2.set(keyFn(data[i]), data[i]);
|
|
3543
|
+
}
|
|
3544
|
+
return map2;
|
|
3545
|
+
};
|
|
3546
|
+
Arr2.frequencies = (data) => {
|
|
3547
|
+
const map2 = new globalThis.Map();
|
|
3548
|
+
for (let i = 0; i < data.length; i++) {
|
|
3549
|
+
const item = data[i];
|
|
3550
|
+
map2.set(item, (map2.get(item) ?? 0) + 1);
|
|
3551
|
+
}
|
|
3552
|
+
return map2;
|
|
3553
|
+
};
|
|
3554
|
+
Arr2.chunkBy = (keyFn) => (data) => {
|
|
3555
|
+
if (data.length === 0) {
|
|
3556
|
+
return [];
|
|
3557
|
+
}
|
|
3558
|
+
const result = [];
|
|
3559
|
+
let currentChunk = [data[0]];
|
|
3560
|
+
let currentKey = keyFn(data[0]);
|
|
3561
|
+
for (let i = 1; i < data.length; i++) {
|
|
3562
|
+
const item = data[i];
|
|
3563
|
+
const key = keyFn(item);
|
|
3564
|
+
if (Object.is(key, currentKey)) {
|
|
3565
|
+
currentChunk.push(item);
|
|
3566
|
+
} else {
|
|
3567
|
+
result.push(currentChunk);
|
|
3568
|
+
currentChunk = [item];
|
|
3569
|
+
currentKey = key;
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
result.push(currentChunk);
|
|
3573
|
+
return result;
|
|
3574
|
+
};
|
|
3575
|
+
Arr2.dedupeAdjacent = (eq = (a, b) => Object.is(a, b)) => (data) => {
|
|
3576
|
+
if (data.length === 0) {
|
|
3577
|
+
return [];
|
|
3578
|
+
}
|
|
3579
|
+
const result = [data[0]];
|
|
3580
|
+
for (let i = 1; i < data.length; i++) {
|
|
3581
|
+
if (!eq(data[i], result[result.length - 1])) {
|
|
3582
|
+
result.push(data[i]);
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
return result;
|
|
3586
|
+
};
|
|
3587
|
+
Arr2.windowed = (size2, options) => (data) => {
|
|
3588
|
+
const step = options?.step ?? 1;
|
|
3589
|
+
if (size2 <= 0 || step <= 0 || data.length < size2) {
|
|
3590
|
+
return [];
|
|
3591
|
+
}
|
|
3592
|
+
const result = [];
|
|
3593
|
+
for (let i = 0; i <= data.length - size2; i += step) {
|
|
3594
|
+
result.push(data.slice(i, i + size2));
|
|
3595
|
+
}
|
|
3596
|
+
return result;
|
|
3597
|
+
};
|
|
3598
|
+
Arr2.unfold = (initial, f) => {
|
|
3599
|
+
const result = [];
|
|
3600
|
+
let currentState = initial;
|
|
3601
|
+
while (true) {
|
|
3602
|
+
const next = f(currentState);
|
|
3603
|
+
if (next.kind === "None") {
|
|
3604
|
+
break;
|
|
3605
|
+
}
|
|
3606
|
+
const [item, nextState] = next.value;
|
|
3607
|
+
result.push(item);
|
|
3608
|
+
currentState = nextState;
|
|
3609
|
+
}
|
|
3610
|
+
return result;
|
|
3611
|
+
};
|
|
3167
3612
|
Arr2.NonEmpty = ArrNonEmpty;
|
|
3168
3613
|
})(Arr || (Arr = {}));
|
|
3169
3614
|
|
|
3615
|
+
// src/Data/BigNum.ts
|
|
3616
|
+
var BigNum;
|
|
3617
|
+
((BigNum2) => {
|
|
3618
|
+
let from;
|
|
3619
|
+
((from2) => {
|
|
3620
|
+
from2.string = (s) => {
|
|
3621
|
+
try {
|
|
3622
|
+
if (s.trim() === "") {
|
|
3623
|
+
return Maybe.make.none();
|
|
3624
|
+
}
|
|
3625
|
+
return Maybe.make.some(BigInt(s));
|
|
3626
|
+
} catch {
|
|
3627
|
+
return Maybe.make.none();
|
|
3628
|
+
}
|
|
3629
|
+
};
|
|
3630
|
+
from2.number = (n) => {
|
|
3631
|
+
if (!Number.isInteger(n) || n < Number.MIN_SAFE_INTEGER || n > Number.MAX_SAFE_INTEGER) {
|
|
3632
|
+
return Maybe.make.none();
|
|
3633
|
+
}
|
|
3634
|
+
return Maybe.make.some(BigInt(n));
|
|
3635
|
+
};
|
|
3636
|
+
})(from = BigNum2.from || (BigNum2.from = {}));
|
|
3637
|
+
let to;
|
|
3638
|
+
((to2) => {
|
|
3639
|
+
to2.number = (b) => {
|
|
3640
|
+
if (b < BigInt(Number.MIN_SAFE_INTEGER) || b > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
3641
|
+
return Maybe.make.none();
|
|
3642
|
+
}
|
|
3643
|
+
return Maybe.make.some(Number(b));
|
|
3644
|
+
};
|
|
3645
|
+
})(to = BigNum2.to || (BigNum2.to = {}));
|
|
3646
|
+
BigNum2.add = (b) => (a) => a + b;
|
|
3647
|
+
BigNum2.sub = (b) => (a) => a - b;
|
|
3648
|
+
BigNum2.mul = (b) => (a) => a * b;
|
|
3649
|
+
BigNum2.div = (b) => (a) => b === 0n ? Maybe.make.none() : Maybe.make.some(a / b);
|
|
3650
|
+
BigNum2.mod = (b) => (a) => b === 0n ? Maybe.make.none() : Maybe.make.some(a % b);
|
|
3651
|
+
BigNum2.clamp = (min2, max2) => (a) => a < min2 ? min2 : a > max2 ? max2 : a;
|
|
3652
|
+
BigNum2.inRange = (start, end) => (a) => a >= start && a < end;
|
|
3653
|
+
BigNum2.abs = (a) => a < 0n ? -a : a;
|
|
3654
|
+
BigNum2.min = (b) => (a) => a < b ? a : b;
|
|
3655
|
+
BigNum2.max = (b) => (a) => a > b ? a : b;
|
|
3656
|
+
})(BigNum || (BigNum = {}));
|
|
3657
|
+
|
|
3170
3658
|
// src/Data/Dict.ts
|
|
3171
3659
|
var DictNonEmpty;
|
|
3172
3660
|
((DictNonEmpty2) => {
|
|
@@ -3323,16 +3811,86 @@ var Dict;
|
|
|
3323
3811
|
}
|
|
3324
3812
|
return acc;
|
|
3325
3813
|
};
|
|
3814
|
+
function mergeWith(combine) {
|
|
3815
|
+
return (arg1, arg2) => {
|
|
3816
|
+
if (arg2 !== void 0) {
|
|
3817
|
+
const first = arg1;
|
|
3818
|
+
const second2 = arg2;
|
|
3819
|
+
const res = new globalThis.Map(first);
|
|
3820
|
+
for (const [k, v] of second2) {
|
|
3821
|
+
if (res.has(k)) {
|
|
3822
|
+
res.set(k, combine(res.get(k), v));
|
|
3823
|
+
} else {
|
|
3824
|
+
res.set(k, v);
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
return res;
|
|
3828
|
+
}
|
|
3829
|
+
const second = arg1;
|
|
3830
|
+
return (first) => {
|
|
3831
|
+
const res = new globalThis.Map(first);
|
|
3832
|
+
for (const [k, v] of second) {
|
|
3833
|
+
if (res.has(k)) {
|
|
3834
|
+
res.set(k, combine(res.get(k), v));
|
|
3835
|
+
} else {
|
|
3836
|
+
res.set(k, v);
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
return res;
|
|
3840
|
+
};
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
Dict2.mergeWith = mergeWith;
|
|
3326
3844
|
let to;
|
|
3327
3845
|
((to2) => {
|
|
3328
3846
|
to2.Record = (m) => Object.fromEntries(m);
|
|
3329
3847
|
})(to = Dict2.to || (Dict2.to = {}));
|
|
3848
|
+
Dict2.mapEntries = (f) => (data) => {
|
|
3849
|
+
const res = new globalThis.Map();
|
|
3850
|
+
for (const [k, v] of data) {
|
|
3851
|
+
const [nk, nv] = f(k, v);
|
|
3852
|
+
res.set(nk, nv);
|
|
3853
|
+
}
|
|
3854
|
+
return res;
|
|
3855
|
+
};
|
|
3856
|
+
Dict2.mapKeys = (f) => (data) => {
|
|
3857
|
+
const res = new globalThis.Map();
|
|
3858
|
+
for (const [k, v] of data) {
|
|
3859
|
+
res.set(f(k), v);
|
|
3860
|
+
}
|
|
3861
|
+
return res;
|
|
3862
|
+
};
|
|
3330
3863
|
Dict2.NonEmpty = DictNonEmpty;
|
|
3331
3864
|
})(Dict || (Dict = {}));
|
|
3332
3865
|
|
|
3866
|
+
// src/Data/Json.ts
|
|
3867
|
+
var isSyntaxError = (err2) => typeof err2 === "object" && err2 !== null && "name" in err2 && err2.name === "SyntaxError";
|
|
3868
|
+
var isTypeError = (err2) => typeof err2 === "object" && err2 !== null && "name" in err2 && err2.name === "TypeError";
|
|
3869
|
+
var Json;
|
|
3870
|
+
((Json2) => {
|
|
3871
|
+
Json2.parse = (text) => Result.tryCatch(() => JSON.parse(text), {
|
|
3872
|
+
onError: (err2) => isSyntaxError(err2) ? err2 : new SyntaxError(String(err2))
|
|
3873
|
+
});
|
|
3874
|
+
Json2.stringify = (value, replacer, space) => Result.tryCatch(() => JSON.stringify(value, replacer, space), {
|
|
3875
|
+
onError: (err2) => isTypeError(err2) ? err2 : new TypeError(String(err2))
|
|
3876
|
+
});
|
|
3877
|
+
})(Json || (Json = {}));
|
|
3878
|
+
|
|
3333
3879
|
// src/Data/Num.ts
|
|
3334
3880
|
var Num;
|
|
3335
3881
|
((Num2) => {
|
|
3882
|
+
let is;
|
|
3883
|
+
((is2) => {
|
|
3884
|
+
is2.zero = (n) => n === 0;
|
|
3885
|
+
is2.integer = (n) => Number.isInteger(n);
|
|
3886
|
+
is2.float = (n) => Number.isFinite(n) && !Number.isInteger(n);
|
|
3887
|
+
is2.finite = (n) => Number.isFinite(n);
|
|
3888
|
+
is2.nan = (n) => Number.isNaN(n);
|
|
3889
|
+
is2.even = (n) => Number.isInteger(n) && n % 2 === 0;
|
|
3890
|
+
is2.odd = (n) => Number.isInteger(n) && n % 2 !== 0;
|
|
3891
|
+
is2.positive = (n) => n > 0;
|
|
3892
|
+
is2.negative = (n) => n < 0;
|
|
3893
|
+
})(is = Num2.is || (Num2.is = {}));
|
|
3336
3894
|
Num2.range = (from, to, step = 1) => {
|
|
3337
3895
|
if (step <= 0 || from > to) {
|
|
3338
3896
|
return [];
|
|
@@ -3396,6 +3954,7 @@ var Num;
|
|
|
3396
3954
|
}
|
|
3397
3955
|
return Maybe.make.some(result);
|
|
3398
3956
|
};
|
|
3957
|
+
Num2.format = (options, locales) => (n) => !Number.isFinite(n) ? Maybe.make.none() : Maybe.make.some(new Intl.NumberFormat(locales, options).format(n));
|
|
3399
3958
|
})(Num || (Num = {}));
|
|
3400
3959
|
|
|
3401
3960
|
// src/Data/Rec.ts
|
|
@@ -3583,6 +4142,36 @@ var Rec;
|
|
|
3583
4142
|
...data,
|
|
3584
4143
|
...other
|
|
3585
4144
|
});
|
|
4145
|
+
function mergeWith(combine) {
|
|
4146
|
+
return (arg1, arg2) => {
|
|
4147
|
+
if (arg2 !== void 0) {
|
|
4148
|
+
const first = arg1;
|
|
4149
|
+
const second2 = arg2;
|
|
4150
|
+
const result = { ...first };
|
|
4151
|
+
for (const [k, v] of Object.entries(second2)) {
|
|
4152
|
+
if (Object.hasOwn(result, k)) {
|
|
4153
|
+
result[k] = combine(result[k], v);
|
|
4154
|
+
} else {
|
|
4155
|
+
result[k] = v;
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
return result;
|
|
4159
|
+
}
|
|
4160
|
+
const second = arg1;
|
|
4161
|
+
return (first) => {
|
|
4162
|
+
const result = { ...first };
|
|
4163
|
+
for (const [k, v] of Object.entries(second)) {
|
|
4164
|
+
if (Object.hasOwn(result, k)) {
|
|
4165
|
+
result[k] = combine(result[k], v);
|
|
4166
|
+
} else {
|
|
4167
|
+
result[k] = v;
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
4170
|
+
return result;
|
|
4171
|
+
};
|
|
4172
|
+
};
|
|
4173
|
+
}
|
|
4174
|
+
Rec2.mergeWith = mergeWith;
|
|
3586
4175
|
Rec2.size = (data) => Object.keys(data).length;
|
|
3587
4176
|
Rec2.mapKeys = (f) => (data) => {
|
|
3588
4177
|
const result = {};
|
|
@@ -3600,6 +4189,25 @@ var Rec;
|
|
|
3600
4189
|
}
|
|
3601
4190
|
return result;
|
|
3602
4191
|
};
|
|
4192
|
+
Rec2.mapEntries = (f) => (data) => {
|
|
4193
|
+
const result = {};
|
|
4194
|
+
for (const [k, v] of Object.entries(data)) {
|
|
4195
|
+
const [newKey, newVal] = f(k, v);
|
|
4196
|
+
Object.defineProperty(result, newKey, { value: newVal, writable: true, enumerable: true, configurable: true });
|
|
4197
|
+
}
|
|
4198
|
+
return result;
|
|
4199
|
+
};
|
|
4200
|
+
Rec2.updateIn = (path, f) => (data) => {
|
|
4201
|
+
const updateNode = (obj, keys2) => {
|
|
4202
|
+
const [head, ...tail] = keys2;
|
|
4203
|
+
if (tail.length === 0) {
|
|
4204
|
+
return { ...obj, [head]: f(obj?.[head]) };
|
|
4205
|
+
}
|
|
4206
|
+
const child = obj && typeof obj === "object" && head in obj ? obj[head] : {};
|
|
4207
|
+
return { ...obj, [head]: updateNode(child, tail) };
|
|
4208
|
+
};
|
|
4209
|
+
return updateNode(data, path);
|
|
4210
|
+
};
|
|
3603
4211
|
let traverse;
|
|
3604
4212
|
((traverse2) => {
|
|
3605
4213
|
traverse2.Maybe = RecMaybe.traverse;
|
|
@@ -3682,6 +4290,17 @@ var Str;
|
|
|
3682
4290
|
return Result.make.err(error);
|
|
3683
4291
|
}
|
|
3684
4292
|
};
|
|
4293
|
+
Str2.uncapitalize = (s) => s.length === 0 ? "" : s.charAt(0).toLowerCase() + s.slice(1);
|
|
4294
|
+
Str2.truncate = (options) => (s) => {
|
|
4295
|
+
const { length: targetLength, suffix = "..." } = options;
|
|
4296
|
+
if (s.length <= targetLength) {
|
|
4297
|
+
return s;
|
|
4298
|
+
}
|
|
4299
|
+
if (targetLength <= suffix.length) {
|
|
4300
|
+
return suffix.slice(0, targetLength);
|
|
4301
|
+
}
|
|
4302
|
+
return s.slice(0, targetLength - suffix.length) + suffix;
|
|
4303
|
+
};
|
|
3685
4304
|
Str2.NonEmpty = StrNonEmpty;
|
|
3686
4305
|
})(Str || (Str = {}));
|
|
3687
4306
|
|
|
@@ -3812,12 +4431,14 @@ var Uniq;
|
|
|
3812
4431
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3813
4432
|
0 && (module.exports = {
|
|
3814
4433
|
Arr,
|
|
4434
|
+
BigNum,
|
|
3815
4435
|
Brand,
|
|
3816
4436
|
Combinable,
|
|
3817
4437
|
Deferred,
|
|
3818
4438
|
Dict,
|
|
3819
4439
|
Duration,
|
|
3820
4440
|
Equality,
|
|
4441
|
+
Json,
|
|
3821
4442
|
Lazy,
|
|
3822
4443
|
Lens,
|
|
3823
4444
|
Logged,
|
|
@@ -3833,8 +4454,10 @@ var Uniq;
|
|
|
3833
4454
|
RemoteData,
|
|
3834
4455
|
Resource,
|
|
3835
4456
|
Result,
|
|
4457
|
+
RetryPolicy,
|
|
3836
4458
|
State,
|
|
3837
4459
|
Str,
|
|
4460
|
+
Stream,
|
|
3838
4461
|
Task,
|
|
3839
4462
|
TaskMaybe,
|
|
3840
4463
|
TaskResult,
|
|
@@ -3868,7 +4491,9 @@ var Uniq;
|
|
|
3868
4491
|
or,
|
|
3869
4492
|
pipe,
|
|
3870
4493
|
tap,
|
|
4494
|
+
tuple,
|
|
3871
4495
|
uncurry,
|
|
3872
4496
|
uncurry3,
|
|
3873
|
-
uncurry4
|
|
4497
|
+
uncurry4,
|
|
4498
|
+
untuple
|
|
3874
4499
|
});
|