@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Duration
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DENXUTKL.mjs";
|
|
4
4
|
|
|
5
5
|
// src/Composition/compose.ts
|
|
6
6
|
function compose(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9) {
|
|
@@ -200,6 +200,8 @@ var once = (f) => {
|
|
|
200
200
|
};
|
|
201
201
|
};
|
|
202
202
|
var defaultTo = (fallback) => (a) => a === null || a === void 0 ? fallback : a;
|
|
203
|
+
var tuple = (f) => (args) => f(...args);
|
|
204
|
+
var untuple = (f) => (...args) => f(args);
|
|
203
205
|
|
|
204
206
|
// src/Composition/juxt.ts
|
|
205
207
|
function juxt(fns) {
|
|
@@ -207,8 +209,9 @@ function juxt(fns) {
|
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
// src/Composition/memoize.ts
|
|
210
|
-
var memoize = (f,
|
|
212
|
+
var memoize = (f, options) => {
|
|
211
213
|
const cache = /* @__PURE__ */ new Map();
|
|
214
|
+
const keyFn = options?.key ?? ((a) => a);
|
|
212
215
|
return (a) => {
|
|
213
216
|
const key = keyFn(a);
|
|
214
217
|
if (cache.has(key)) {
|
|
@@ -434,6 +437,8 @@ export {
|
|
|
434
437
|
or,
|
|
435
438
|
once,
|
|
436
439
|
defaultTo,
|
|
440
|
+
tuple,
|
|
441
|
+
untuple,
|
|
437
442
|
juxt,
|
|
438
443
|
memoize,
|
|
439
444
|
memoizeWeak,
|
|
@@ -26,7 +26,31 @@ var Duration;
|
|
|
26
26
|
Duration2.subtract = (other) => (self) => wrap(Brand.unwrap(self) - Brand.unwrap(other));
|
|
27
27
|
})(Duration || (Duration = {}));
|
|
28
28
|
|
|
29
|
+
// src/Types/RetryPolicy.ts
|
|
30
|
+
var RetryPolicy;
|
|
31
|
+
((RetryPolicy2) => {
|
|
32
|
+
RetryPolicy2.constant = (options) => ({
|
|
33
|
+
attempts: Math.max(1, options.attempts),
|
|
34
|
+
getDelay: () => options.delay
|
|
35
|
+
});
|
|
36
|
+
RetryPolicy2.exponential = (options) => {
|
|
37
|
+
const attempts = Math.max(1, options.attempts);
|
|
38
|
+
const initialMs = Duration.to.milliseconds(options.initial);
|
|
39
|
+
const factor = options.factor ?? 2;
|
|
40
|
+
const jitter = options.jitter ?? false;
|
|
41
|
+
return {
|
|
42
|
+
attempts,
|
|
43
|
+
getDelay: (attempt) => {
|
|
44
|
+
const rawMs = initialMs * factor ** Math.max(0, attempt - 1);
|
|
45
|
+
const finalMs = jitter ? Math.random() * rawMs : rawMs;
|
|
46
|
+
return Duration.milliseconds(finalMs);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
})(RetryPolicy || (RetryPolicy = {}));
|
|
51
|
+
|
|
29
52
|
export {
|
|
30
53
|
Brand,
|
|
54
|
+
RetryPolicy,
|
|
31
55
|
Duration
|
|
32
56
|
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Result,
|
|
5
5
|
Task,
|
|
6
6
|
isNonEmptyArr
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IHLH2XYQ.mjs";
|
|
8
8
|
|
|
9
9
|
// src/Data/Arr.ts
|
|
10
10
|
var ArrMaybe;
|
|
@@ -391,9 +391,154 @@ var Arr;
|
|
|
391
391
|
const i = Math.max(0, index);
|
|
392
392
|
return [data.slice(0, i), data.slice(i)];
|
|
393
393
|
};
|
|
394
|
+
Arr2.partitionMaybe = (f) => (data) => {
|
|
395
|
+
const failures = [];
|
|
396
|
+
const successes = [];
|
|
397
|
+
for (let i = 0; i < data.length; i++) {
|
|
398
|
+
const res = f(data[i]);
|
|
399
|
+
if (res.kind === "Some") {
|
|
400
|
+
successes.push(res.value);
|
|
401
|
+
} else {
|
|
402
|
+
failures.push(data[i]);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return [failures, successes];
|
|
406
|
+
};
|
|
407
|
+
Arr2.at = (index) => (data) => {
|
|
408
|
+
const targetIndex = index < 0 ? data.length + index : index;
|
|
409
|
+
if (targetIndex < 0 || targetIndex >= data.length) {
|
|
410
|
+
return Maybe.make.none();
|
|
411
|
+
}
|
|
412
|
+
return Maybe.make.some(data[targetIndex]);
|
|
413
|
+
};
|
|
414
|
+
Arr2.findMap = (f) => (data) => {
|
|
415
|
+
for (let i = 0; i < data.length; i++) {
|
|
416
|
+
const res = f(data[i]);
|
|
417
|
+
if (res.kind === "Some") {
|
|
418
|
+
return res;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return Maybe.make.none();
|
|
422
|
+
};
|
|
423
|
+
Arr2.indexBy = (keyFn) => (data) => {
|
|
424
|
+
const map2 = new globalThis.Map();
|
|
425
|
+
for (let i = 0; i < data.length; i++) {
|
|
426
|
+
map2.set(keyFn(data[i]), data[i]);
|
|
427
|
+
}
|
|
428
|
+
return map2;
|
|
429
|
+
};
|
|
430
|
+
Arr2.frequencies = (data) => {
|
|
431
|
+
const map2 = new globalThis.Map();
|
|
432
|
+
for (let i = 0; i < data.length; i++) {
|
|
433
|
+
const item = data[i];
|
|
434
|
+
map2.set(item, (map2.get(item) ?? 0) + 1);
|
|
435
|
+
}
|
|
436
|
+
return map2;
|
|
437
|
+
};
|
|
438
|
+
Arr2.chunkBy = (keyFn) => (data) => {
|
|
439
|
+
if (data.length === 0) {
|
|
440
|
+
return [];
|
|
441
|
+
}
|
|
442
|
+
const result = [];
|
|
443
|
+
let currentChunk = [data[0]];
|
|
444
|
+
let currentKey = keyFn(data[0]);
|
|
445
|
+
for (let i = 1; i < data.length; i++) {
|
|
446
|
+
const item = data[i];
|
|
447
|
+
const key = keyFn(item);
|
|
448
|
+
if (Object.is(key, currentKey)) {
|
|
449
|
+
currentChunk.push(item);
|
|
450
|
+
} else {
|
|
451
|
+
result.push(currentChunk);
|
|
452
|
+
currentChunk = [item];
|
|
453
|
+
currentKey = key;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
result.push(currentChunk);
|
|
457
|
+
return result;
|
|
458
|
+
};
|
|
459
|
+
Arr2.dedupeAdjacent = (eq = (a, b) => Object.is(a, b)) => (data) => {
|
|
460
|
+
if (data.length === 0) {
|
|
461
|
+
return [];
|
|
462
|
+
}
|
|
463
|
+
const result = [data[0]];
|
|
464
|
+
for (let i = 1; i < data.length; i++) {
|
|
465
|
+
if (!eq(data[i], result[result.length - 1])) {
|
|
466
|
+
result.push(data[i]);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
};
|
|
471
|
+
Arr2.windowed = (size2, options) => (data) => {
|
|
472
|
+
const step = options?.step ?? 1;
|
|
473
|
+
if (size2 <= 0 || step <= 0 || data.length < size2) {
|
|
474
|
+
return [];
|
|
475
|
+
}
|
|
476
|
+
const result = [];
|
|
477
|
+
for (let i = 0; i <= data.length - size2; i += step) {
|
|
478
|
+
result.push(data.slice(i, i + size2));
|
|
479
|
+
}
|
|
480
|
+
return result;
|
|
481
|
+
};
|
|
482
|
+
Arr2.unfold = (initial, f) => {
|
|
483
|
+
const result = [];
|
|
484
|
+
let currentState = initial;
|
|
485
|
+
while (true) {
|
|
486
|
+
const next = f(currentState);
|
|
487
|
+
if (next.kind === "None") {
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
const [item, nextState] = next.value;
|
|
491
|
+
result.push(item);
|
|
492
|
+
currentState = nextState;
|
|
493
|
+
}
|
|
494
|
+
return result;
|
|
495
|
+
};
|
|
394
496
|
Arr2.NonEmpty = ArrNonEmpty;
|
|
395
497
|
})(Arr || (Arr = {}));
|
|
396
498
|
|
|
499
|
+
// src/Data/BigNum.ts
|
|
500
|
+
var BigNum;
|
|
501
|
+
((BigNum2) => {
|
|
502
|
+
let from;
|
|
503
|
+
((from2) => {
|
|
504
|
+
from2.string = (s) => {
|
|
505
|
+
try {
|
|
506
|
+
if (s.trim() === "") {
|
|
507
|
+
return Maybe.make.none();
|
|
508
|
+
}
|
|
509
|
+
return Maybe.make.some(BigInt(s));
|
|
510
|
+
} catch {
|
|
511
|
+
return Maybe.make.none();
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
from2.number = (n) => {
|
|
515
|
+
if (!Number.isInteger(n) || n < Number.MIN_SAFE_INTEGER || n > Number.MAX_SAFE_INTEGER) {
|
|
516
|
+
return Maybe.make.none();
|
|
517
|
+
}
|
|
518
|
+
return Maybe.make.some(BigInt(n));
|
|
519
|
+
};
|
|
520
|
+
})(from = BigNum2.from || (BigNum2.from = {}));
|
|
521
|
+
let to;
|
|
522
|
+
((to2) => {
|
|
523
|
+
to2.number = (b) => {
|
|
524
|
+
if (b < BigInt(Number.MIN_SAFE_INTEGER) || b > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
525
|
+
return Maybe.make.none();
|
|
526
|
+
}
|
|
527
|
+
return Maybe.make.some(Number(b));
|
|
528
|
+
};
|
|
529
|
+
})(to = BigNum2.to || (BigNum2.to = {}));
|
|
530
|
+
BigNum2.add = (b) => (a) => a + b;
|
|
531
|
+
BigNum2.sub = (b) => (a) => a - b;
|
|
532
|
+
BigNum2.mul = (b) => (a) => a * b;
|
|
533
|
+
BigNum2.div = (b) => (a) => b === 0n ? Maybe.make.none() : Maybe.make.some(a / b);
|
|
534
|
+
BigNum2.mod = (b) => (a) => b === 0n ? Maybe.make.none() : Maybe.make.some(a % b);
|
|
535
|
+
BigNum2.clamp = (min2, max2) => (a) => a < min2 ? min2 : a > max2 ? max2 : a;
|
|
536
|
+
BigNum2.inRange = (start, end) => (a) => a >= start && a < end;
|
|
537
|
+
BigNum2.abs = (a) => a < 0n ? -a : a;
|
|
538
|
+
BigNum2.min = (b) => (a) => a < b ? a : b;
|
|
539
|
+
BigNum2.max = (b) => (a) => a > b ? a : b;
|
|
540
|
+
})(BigNum || (BigNum = {}));
|
|
541
|
+
|
|
397
542
|
// src/Data/Dict.ts
|
|
398
543
|
var DictNonEmpty;
|
|
399
544
|
((DictNonEmpty2) => {
|
|
@@ -550,16 +695,86 @@ var Dict;
|
|
|
550
695
|
}
|
|
551
696
|
return acc;
|
|
552
697
|
};
|
|
698
|
+
function mergeWith(combine) {
|
|
699
|
+
return (arg1, arg2) => {
|
|
700
|
+
if (arg2 !== void 0) {
|
|
701
|
+
const first = arg1;
|
|
702
|
+
const second2 = arg2;
|
|
703
|
+
const res = new globalThis.Map(first);
|
|
704
|
+
for (const [k, v] of second2) {
|
|
705
|
+
if (res.has(k)) {
|
|
706
|
+
res.set(k, combine(res.get(k), v));
|
|
707
|
+
} else {
|
|
708
|
+
res.set(k, v);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return res;
|
|
712
|
+
}
|
|
713
|
+
const second = arg1;
|
|
714
|
+
return (first) => {
|
|
715
|
+
const res = new globalThis.Map(first);
|
|
716
|
+
for (const [k, v] of second) {
|
|
717
|
+
if (res.has(k)) {
|
|
718
|
+
res.set(k, combine(res.get(k), v));
|
|
719
|
+
} else {
|
|
720
|
+
res.set(k, v);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return res;
|
|
724
|
+
};
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
Dict2.mergeWith = mergeWith;
|
|
553
728
|
let to;
|
|
554
729
|
((to2) => {
|
|
555
730
|
to2.Record = (m) => Object.fromEntries(m);
|
|
556
731
|
})(to = Dict2.to || (Dict2.to = {}));
|
|
732
|
+
Dict2.mapEntries = (f) => (data) => {
|
|
733
|
+
const res = new globalThis.Map();
|
|
734
|
+
for (const [k, v] of data) {
|
|
735
|
+
const [nk, nv] = f(k, v);
|
|
736
|
+
res.set(nk, nv);
|
|
737
|
+
}
|
|
738
|
+
return res;
|
|
739
|
+
};
|
|
740
|
+
Dict2.mapKeys = (f) => (data) => {
|
|
741
|
+
const res = new globalThis.Map();
|
|
742
|
+
for (const [k, v] of data) {
|
|
743
|
+
res.set(f(k), v);
|
|
744
|
+
}
|
|
745
|
+
return res;
|
|
746
|
+
};
|
|
557
747
|
Dict2.NonEmpty = DictNonEmpty;
|
|
558
748
|
})(Dict || (Dict = {}));
|
|
559
749
|
|
|
750
|
+
// src/Data/Json.ts
|
|
751
|
+
var isSyntaxError = (err) => typeof err === "object" && err !== null && "name" in err && err.name === "SyntaxError";
|
|
752
|
+
var isTypeError = (err) => typeof err === "object" && err !== null && "name" in err && err.name === "TypeError";
|
|
753
|
+
var Json;
|
|
754
|
+
((Json2) => {
|
|
755
|
+
Json2.parse = (text) => Result.tryCatch(() => JSON.parse(text), {
|
|
756
|
+
onError: (err) => isSyntaxError(err) ? err : new SyntaxError(String(err))
|
|
757
|
+
});
|
|
758
|
+
Json2.stringify = (value, replacer, space) => Result.tryCatch(() => JSON.stringify(value, replacer, space), {
|
|
759
|
+
onError: (err) => isTypeError(err) ? err : new TypeError(String(err))
|
|
760
|
+
});
|
|
761
|
+
})(Json || (Json = {}));
|
|
762
|
+
|
|
560
763
|
// src/Data/Num.ts
|
|
561
764
|
var Num;
|
|
562
765
|
((Num2) => {
|
|
766
|
+
let is;
|
|
767
|
+
((is2) => {
|
|
768
|
+
is2.zero = (n) => n === 0;
|
|
769
|
+
is2.integer = (n) => Number.isInteger(n);
|
|
770
|
+
is2.float = (n) => Number.isFinite(n) && !Number.isInteger(n);
|
|
771
|
+
is2.finite = (n) => Number.isFinite(n);
|
|
772
|
+
is2.nan = (n) => Number.isNaN(n);
|
|
773
|
+
is2.even = (n) => Number.isInteger(n) && n % 2 === 0;
|
|
774
|
+
is2.odd = (n) => Number.isInteger(n) && n % 2 !== 0;
|
|
775
|
+
is2.positive = (n) => n > 0;
|
|
776
|
+
is2.negative = (n) => n < 0;
|
|
777
|
+
})(is = Num2.is || (Num2.is = {}));
|
|
563
778
|
Num2.range = (from, to, step = 1) => {
|
|
564
779
|
if (step <= 0 || from > to) {
|
|
565
780
|
return [];
|
|
@@ -623,6 +838,7 @@ var Num;
|
|
|
623
838
|
}
|
|
624
839
|
return Maybe.make.some(result);
|
|
625
840
|
};
|
|
841
|
+
Num2.format = (options, locales) => (n) => !Number.isFinite(n) ? Maybe.make.none() : Maybe.make.some(new Intl.NumberFormat(locales, options).format(n));
|
|
626
842
|
})(Num || (Num = {}));
|
|
627
843
|
|
|
628
844
|
// src/Data/Rec.ts
|
|
@@ -810,6 +1026,36 @@ var Rec;
|
|
|
810
1026
|
...data,
|
|
811
1027
|
...other
|
|
812
1028
|
});
|
|
1029
|
+
function mergeWith(combine) {
|
|
1030
|
+
return (arg1, arg2) => {
|
|
1031
|
+
if (arg2 !== void 0) {
|
|
1032
|
+
const first = arg1;
|
|
1033
|
+
const second2 = arg2;
|
|
1034
|
+
const result = { ...first };
|
|
1035
|
+
for (const [k, v] of Object.entries(second2)) {
|
|
1036
|
+
if (Object.hasOwn(result, k)) {
|
|
1037
|
+
result[k] = combine(result[k], v);
|
|
1038
|
+
} else {
|
|
1039
|
+
result[k] = v;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return result;
|
|
1043
|
+
}
|
|
1044
|
+
const second = arg1;
|
|
1045
|
+
return (first) => {
|
|
1046
|
+
const result = { ...first };
|
|
1047
|
+
for (const [k, v] of Object.entries(second)) {
|
|
1048
|
+
if (Object.hasOwn(result, k)) {
|
|
1049
|
+
result[k] = combine(result[k], v);
|
|
1050
|
+
} else {
|
|
1051
|
+
result[k] = v;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
return result;
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
Rec2.mergeWith = mergeWith;
|
|
813
1059
|
Rec2.size = (data) => Object.keys(data).length;
|
|
814
1060
|
Rec2.mapKeys = (f) => (data) => {
|
|
815
1061
|
const result = {};
|
|
@@ -827,6 +1073,25 @@ var Rec;
|
|
|
827
1073
|
}
|
|
828
1074
|
return result;
|
|
829
1075
|
};
|
|
1076
|
+
Rec2.mapEntries = (f) => (data) => {
|
|
1077
|
+
const result = {};
|
|
1078
|
+
for (const [k, v] of Object.entries(data)) {
|
|
1079
|
+
const [newKey, newVal] = f(k, v);
|
|
1080
|
+
Object.defineProperty(result, newKey, { value: newVal, writable: true, enumerable: true, configurable: true });
|
|
1081
|
+
}
|
|
1082
|
+
return result;
|
|
1083
|
+
};
|
|
1084
|
+
Rec2.updateIn = (path, f) => (data) => {
|
|
1085
|
+
const updateNode = (obj, keys2) => {
|
|
1086
|
+
const [head, ...tail] = keys2;
|
|
1087
|
+
if (tail.length === 0) {
|
|
1088
|
+
return { ...obj, [head]: f(obj?.[head]) };
|
|
1089
|
+
}
|
|
1090
|
+
const child = obj && typeof obj === "object" && head in obj ? obj[head] : {};
|
|
1091
|
+
return { ...obj, [head]: updateNode(child, tail) };
|
|
1092
|
+
};
|
|
1093
|
+
return updateNode(data, path);
|
|
1094
|
+
};
|
|
830
1095
|
let traverse;
|
|
831
1096
|
((traverse2) => {
|
|
832
1097
|
traverse2.Maybe = RecMaybe.traverse;
|
|
@@ -909,6 +1174,17 @@ var Str;
|
|
|
909
1174
|
return Result.make.err(error);
|
|
910
1175
|
}
|
|
911
1176
|
};
|
|
1177
|
+
Str2.uncapitalize = (s) => s.length === 0 ? "" : s.charAt(0).toLowerCase() + s.slice(1);
|
|
1178
|
+
Str2.truncate = (options) => (s) => {
|
|
1179
|
+
const { length: targetLength, suffix = "..." } = options;
|
|
1180
|
+
if (s.length <= targetLength) {
|
|
1181
|
+
return s;
|
|
1182
|
+
}
|
|
1183
|
+
if (targetLength <= suffix.length) {
|
|
1184
|
+
return suffix.slice(0, targetLength);
|
|
1185
|
+
}
|
|
1186
|
+
return s.slice(0, targetLength - suffix.length) + suffix;
|
|
1187
|
+
};
|
|
912
1188
|
Str2.NonEmpty = StrNonEmpty;
|
|
913
1189
|
})(Str || (Str = {}));
|
|
914
1190
|
|
|
@@ -1039,7 +1315,9 @@ var Uniq;
|
|
|
1039
1315
|
|
|
1040
1316
|
export {
|
|
1041
1317
|
Arr,
|
|
1318
|
+
BigNum,
|
|
1042
1319
|
Dict,
|
|
1320
|
+
Json,
|
|
1043
1321
|
Num,
|
|
1044
1322
|
Rec,
|
|
1045
1323
|
Str,
|