@nlozgachev/pipelined 0.56.0 → 0.58.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/dist/{Validation-DCqWoCC2.d.cts → Validation-DC3uUizM.d.cts} +54 -0
- package/dist/{Validation-t0k4ic-S.d.ts → Validation-DZLizBZ0.d.ts} +54 -0
- package/dist/{chunk-EJX32LRO.js → chunk-FVWJMPQI.js} +1 -1
- package/dist/{chunk-K7HHEACE.js → chunk-VYHAA4KO.js} +40 -29
- package/dist/core.cjs +41 -30
- package/dist/core.d.cts +145 -145
- package/dist/core.d.ts +145 -145
- package/dist/core.js +3 -3
- package/dist/data.d.cts +1 -1
- package/dist/data.d.ts +1 -1
- package/dist/data.js +2 -2
- package/dist/index.cjs +41 -30
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/package.json +1 -1
|
@@ -1266,6 +1266,22 @@ declare namespace TaskResult {
|
|
|
1266
1266
|
* The fallback can produce a different success type, widening the result to `Task.Result<E, A | B>`.
|
|
1267
1267
|
*/
|
|
1268
1268
|
const recover: <E, B>(fallback: (e: E) => TaskResult<E, B>) => <A>(data: TaskResult<E, A>) => TaskResult<E, A | B>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Recovers from an error unless the predicate `isBlocked` returns true for that error.
|
|
1271
|
+
* The fallback can produce a different success type, widening the result to `Task.Result<E, A | B>`.
|
|
1272
|
+
*
|
|
1273
|
+
* @example
|
|
1274
|
+
* ```ts
|
|
1275
|
+
* pipe(
|
|
1276
|
+
* fetchTask,
|
|
1277
|
+
* Task.Result.recoverUnless(
|
|
1278
|
+
* (e) => e === "fatal",
|
|
1279
|
+
* () => Task.Result.ok("fallback")
|
|
1280
|
+
* )
|
|
1281
|
+
* );
|
|
1282
|
+
* ```
|
|
1283
|
+
*/
|
|
1284
|
+
const recoverUnless: <E, B>(isBlocked: (e: E) => boolean, fallback: (e: E) => TaskResult<E, B>) => <A>(data: TaskResult<E, A>) => TaskResult<E, A | B>;
|
|
1269
1285
|
/**
|
|
1270
1286
|
* Returns the success value or a default value if the Task.Result is an error.
|
|
1271
1287
|
* The default can be a different type, widening the result to `Task<A | B>`.
|
|
@@ -1501,6 +1517,28 @@ declare namespace TaskValidation {
|
|
|
1501
1517
|
*/
|
|
1502
1518
|
const Result: <E, A>(result: Result<E, A>) => TaskValidation<E, A>;
|
|
1503
1519
|
}
|
|
1520
|
+
namespace to {
|
|
1521
|
+
/**
|
|
1522
|
+
* Converts a `Task.Validation` to a `Task.Result`, combining accumulated errors using `combineErrors`.
|
|
1523
|
+
* `Passed(a)` becomes `Ok(a)`; `Failed(errors)` becomes `Err(combineErrors(errors))`.
|
|
1524
|
+
*
|
|
1525
|
+
* @example
|
|
1526
|
+
* ```ts
|
|
1527
|
+
* Task.Validation.to.Result((errors) => errors.join(", "))(validationTask);
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
const Result: <E1, E2, A>(combineErrors: (errors: NonEmptyArr<E1>) => E2) => (data: TaskValidation<E1, A>) => TaskResult<E2, A>;
|
|
1531
|
+
/**
|
|
1532
|
+
* Converts a `Task.Validation` to a `Task.Maybe`.
|
|
1533
|
+
* `Passed(a)` becomes `Some(a)`; `Failed(errors)` becomes `None` (errors are discarded).
|
|
1534
|
+
*
|
|
1535
|
+
* @example
|
|
1536
|
+
* ```ts
|
|
1537
|
+
* Task.Validation.to.Maybe(validationTask);
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
const Maybe: <E, A>(data: TaskValidation<E, A>) => TaskMaybe<A>;
|
|
1541
|
+
}
|
|
1504
1542
|
/**
|
|
1505
1543
|
* Creates a Task.Validation from a Promise-returning function.
|
|
1506
1544
|
* Catches any errors and transforms them using the onError function.
|
|
@@ -1578,6 +1616,22 @@ declare namespace TaskValidation {
|
|
|
1578
1616
|
* The fallback can produce a different success type, widening the result to `Task.Validation<E, A | B>`.
|
|
1579
1617
|
*/
|
|
1580
1618
|
const recover: <E, B>(fallback: (errors: NonEmptyArr<E>) => TaskValidation<E, B>) => <A>(data: TaskValidation<E, A>) => TaskValidation<E, A | B>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Recovers from a Failed state unless the predicate `isBlocked` returns true for the accumulated errors.
|
|
1621
|
+
* The fallback receives the accumulated errors and can produce a different success type, widening the result to `Task.Validation<E, A | B>`.
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```ts
|
|
1625
|
+
* pipe(
|
|
1626
|
+
* validationTask,
|
|
1627
|
+
* Task.Validation.recoverUnless(
|
|
1628
|
+
* (errors) => errors.includes("fatal"),
|
|
1629
|
+
* (errors) => Task.Validation.passed("fallback")
|
|
1630
|
+
* )
|
|
1631
|
+
* );
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
const recoverUnless: <E, B>(isBlocked: (errors: NonEmptyArr<E>) => boolean, fallback: (errors: NonEmptyArr<E>) => TaskValidation<E, B>) => <A>(data: TaskValidation<E, A>) => TaskValidation<E, A | B>;
|
|
1581
1635
|
/**
|
|
1582
1636
|
* Runs two Task.Validations concurrently and combines their results into a tuple.
|
|
1583
1637
|
* If both are Passed, returns Passed with both values. If either fails, accumulates
|
|
@@ -1266,6 +1266,22 @@ declare namespace TaskResult {
|
|
|
1266
1266
|
* The fallback can produce a different success type, widening the result to `Task.Result<E, A | B>`.
|
|
1267
1267
|
*/
|
|
1268
1268
|
const recover: <E, B>(fallback: (e: E) => TaskResult<E, B>) => <A>(data: TaskResult<E, A>) => TaskResult<E, A | B>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Recovers from an error unless the predicate `isBlocked` returns true for that error.
|
|
1271
|
+
* The fallback can produce a different success type, widening the result to `Task.Result<E, A | B>`.
|
|
1272
|
+
*
|
|
1273
|
+
* @example
|
|
1274
|
+
* ```ts
|
|
1275
|
+
* pipe(
|
|
1276
|
+
* fetchTask,
|
|
1277
|
+
* Task.Result.recoverUnless(
|
|
1278
|
+
* (e) => e === "fatal",
|
|
1279
|
+
* () => Task.Result.ok("fallback")
|
|
1280
|
+
* )
|
|
1281
|
+
* );
|
|
1282
|
+
* ```
|
|
1283
|
+
*/
|
|
1284
|
+
const recoverUnless: <E, B>(isBlocked: (e: E) => boolean, fallback: (e: E) => TaskResult<E, B>) => <A>(data: TaskResult<E, A>) => TaskResult<E, A | B>;
|
|
1269
1285
|
/**
|
|
1270
1286
|
* Returns the success value or a default value if the Task.Result is an error.
|
|
1271
1287
|
* The default can be a different type, widening the result to `Task<A | B>`.
|
|
@@ -1501,6 +1517,28 @@ declare namespace TaskValidation {
|
|
|
1501
1517
|
*/
|
|
1502
1518
|
const Result: <E, A>(result: Result<E, A>) => TaskValidation<E, A>;
|
|
1503
1519
|
}
|
|
1520
|
+
namespace to {
|
|
1521
|
+
/**
|
|
1522
|
+
* Converts a `Task.Validation` to a `Task.Result`, combining accumulated errors using `combineErrors`.
|
|
1523
|
+
* `Passed(a)` becomes `Ok(a)`; `Failed(errors)` becomes `Err(combineErrors(errors))`.
|
|
1524
|
+
*
|
|
1525
|
+
* @example
|
|
1526
|
+
* ```ts
|
|
1527
|
+
* Task.Validation.to.Result((errors) => errors.join(", "))(validationTask);
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
const Result: <E1, E2, A>(combineErrors: (errors: NonEmptyArr<E1>) => E2) => (data: TaskValidation<E1, A>) => TaskResult<E2, A>;
|
|
1531
|
+
/**
|
|
1532
|
+
* Converts a `Task.Validation` to a `Task.Maybe`.
|
|
1533
|
+
* `Passed(a)` becomes `Some(a)`; `Failed(errors)` becomes `None` (errors are discarded).
|
|
1534
|
+
*
|
|
1535
|
+
* @example
|
|
1536
|
+
* ```ts
|
|
1537
|
+
* Task.Validation.to.Maybe(validationTask);
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
const Maybe: <E, A>(data: TaskValidation<E, A>) => TaskMaybe<A>;
|
|
1541
|
+
}
|
|
1504
1542
|
/**
|
|
1505
1543
|
* Creates a Task.Validation from a Promise-returning function.
|
|
1506
1544
|
* Catches any errors and transforms them using the onError function.
|
|
@@ -1578,6 +1616,22 @@ declare namespace TaskValidation {
|
|
|
1578
1616
|
* The fallback can produce a different success type, widening the result to `Task.Validation<E, A | B>`.
|
|
1579
1617
|
*/
|
|
1580
1618
|
const recover: <E, B>(fallback: (errors: NonEmptyArr<E>) => TaskValidation<E, B>) => <A>(data: TaskValidation<E, A>) => TaskValidation<E, A | B>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Recovers from a Failed state unless the predicate `isBlocked` returns true for the accumulated errors.
|
|
1621
|
+
* The fallback receives the accumulated errors and can produce a different success type, widening the result to `Task.Validation<E, A | B>`.
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```ts
|
|
1625
|
+
* pipe(
|
|
1626
|
+
* validationTask,
|
|
1627
|
+
* Task.Validation.recoverUnless(
|
|
1628
|
+
* (errors) => errors.includes("fatal"),
|
|
1629
|
+
* (errors) => Task.Validation.passed("fallback")
|
|
1630
|
+
* )
|
|
1631
|
+
* );
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
const recoverUnless: <E, B>(isBlocked: (errors: NonEmptyArr<E>) => boolean, fallback: (errors: NonEmptyArr<E>) => TaskValidation<E, B>) => <A>(data: TaskValidation<E, A>) => TaskValidation<E, A | B>;
|
|
1581
1635
|
/**
|
|
1582
1636
|
* Runs two Task.Validations concurrently and combines their results into a tuple.
|
|
1583
1637
|
* If both are Passed, returns Passed with both values. If either fails, accumulates
|
|
@@ -1402,6 +1402,34 @@ var Ordering;
|
|
|
1402
1402
|
};
|
|
1403
1403
|
})(Ordering || (Ordering = {}));
|
|
1404
1404
|
|
|
1405
|
+
// src/Core/Pair.ts
|
|
1406
|
+
var Pair;
|
|
1407
|
+
((Pair2) => {
|
|
1408
|
+
let from;
|
|
1409
|
+
((from2) => {
|
|
1410
|
+
from2.pair = (first2, second2) => [first2, second2];
|
|
1411
|
+
from2.array = (arr) => arr;
|
|
1412
|
+
})(from = Pair2.from || (Pair2.from = {}));
|
|
1413
|
+
Pair2.first = (p) => p[0];
|
|
1414
|
+
Pair2.second = (p) => p[1];
|
|
1415
|
+
Pair2.mapFirst = (f) => (p) => [f(p[0]), p[1]];
|
|
1416
|
+
Pair2.mapSecond = (f) => (p) => [p[0], f(p[1])];
|
|
1417
|
+
Pair2.mapBoth = (onFirst, onSecond) => (p) => [
|
|
1418
|
+
onFirst(p[0]),
|
|
1419
|
+
onSecond(p[1])
|
|
1420
|
+
];
|
|
1421
|
+
Pair2.fold = (f) => (p) => f(p[0], p[1]);
|
|
1422
|
+
Pair2.swap = (p) => [p[1], p[0]];
|
|
1423
|
+
let to;
|
|
1424
|
+
((to2) => {
|
|
1425
|
+
to2.Array = (p) => [...p];
|
|
1426
|
+
})(to = Pair2.to || (Pair2.to = {}));
|
|
1427
|
+
Pair2.tap = (f) => (p) => {
|
|
1428
|
+
f(p[0], p[1]);
|
|
1429
|
+
return p;
|
|
1430
|
+
};
|
|
1431
|
+
})(Pair || (Pair = {}));
|
|
1432
|
+
|
|
1405
1433
|
// src/Core/Predicate.ts
|
|
1406
1434
|
var Predicate;
|
|
1407
1435
|
((Predicate2) => {
|
|
@@ -1951,6 +1979,9 @@ var TaskResult;
|
|
|
1951
1979
|
TaskResult2.recover = (fallback) => (data) => Task.chain(
|
|
1952
1980
|
(result) => Result.is.err(result) ? fallback(result.error) : Task.resolve(result)
|
|
1953
1981
|
)(data);
|
|
1982
|
+
TaskResult2.recoverUnless = (isBlocked, fallback) => (data) => Task.chain(
|
|
1983
|
+
(result) => Result.is.err(result) && !isBlocked(result.error) ? fallback(result.error) : Task.resolve(result)
|
|
1984
|
+
)(data);
|
|
1954
1985
|
TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
|
|
1955
1986
|
TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
|
|
1956
1987
|
TaskResult2.tapError = (f) => (data) => Task.map(Result.tapError(f))(data);
|
|
@@ -2061,6 +2092,11 @@ var TaskValidation;
|
|
|
2061
2092
|
);
|
|
2062
2093
|
from2.Result = (result) => Task.resolve(Validation.from.Result(result));
|
|
2063
2094
|
})(from = TaskValidation2.from || (TaskValidation2.from = {}));
|
|
2095
|
+
let to;
|
|
2096
|
+
((to2) => {
|
|
2097
|
+
to2.Result = (combineErrors) => (data) => Task.map(Validation.to.Result(combineErrors))(data);
|
|
2098
|
+
to2.Maybe = (data) => Task.map(Validation.to.Maybe)(data);
|
|
2099
|
+
})(to = TaskValidation2.to || (TaskValidation2.to = {}));
|
|
2064
2100
|
TaskValidation2.tryCatch = (f, options) => (signal) => Deferred.from.Promise(
|
|
2065
2101
|
globalThis.Promise.resolve().then(async () => f(signal)).then(Validation.make.passed).catch(
|
|
2066
2102
|
(error) => Validation.make.failed(options.onError(error))
|
|
@@ -2079,6 +2115,9 @@ var TaskValidation;
|
|
|
2079
2115
|
TaskValidation2.recover = (fallback) => (data) => Task.chain(
|
|
2080
2116
|
(validation) => Validation.is.passed(validation) ? Task.resolve(validation) : fallback(validation.errors)
|
|
2081
2117
|
)(data);
|
|
2118
|
+
TaskValidation2.recoverUnless = (isBlocked, fallback) => (data) => Task.chain(
|
|
2119
|
+
(validation) => Validation.is.passed(validation) ? Task.resolve(validation) : isBlocked(validation.errors) ? Task.resolve(validation) : fallback(validation.errors)
|
|
2120
|
+
)(data);
|
|
2082
2121
|
TaskValidation2.product = (first, second) => (signal) => Deferred.from.Promise(
|
|
2083
2122
|
Promise.all([Deferred.to.Promise(first(signal)), Deferred.to.Promise(second(signal))]).then(
|
|
2084
2123
|
([va, vb]) => Validation.product(va, vb)
|
|
@@ -2449,34 +2488,6 @@ var These;
|
|
|
2449
2488
|
};
|
|
2450
2489
|
})(These || (These = {}));
|
|
2451
2490
|
|
|
2452
|
-
// src/Core/Tuple.ts
|
|
2453
|
-
var Tuple;
|
|
2454
|
-
((Tuple2) => {
|
|
2455
|
-
let from;
|
|
2456
|
-
((from2) => {
|
|
2457
|
-
from2.pair = (first2, second2) => [first2, second2];
|
|
2458
|
-
from2.array = (arr) => arr;
|
|
2459
|
-
})(from = Tuple2.from || (Tuple2.from = {}));
|
|
2460
|
-
Tuple2.first = (tuple) => tuple[0];
|
|
2461
|
-
Tuple2.second = (tuple) => tuple[1];
|
|
2462
|
-
Tuple2.mapFirst = (f) => (tuple) => [f(tuple[0]), tuple[1]];
|
|
2463
|
-
Tuple2.mapSecond = (f) => (tuple) => [tuple[0], f(tuple[1])];
|
|
2464
|
-
Tuple2.mapBoth = (onFirst, onSecond) => (tuple) => [
|
|
2465
|
-
onFirst(tuple[0]),
|
|
2466
|
-
onSecond(tuple[1])
|
|
2467
|
-
];
|
|
2468
|
-
Tuple2.fold = (f) => (tuple) => f(tuple[0], tuple[1]);
|
|
2469
|
-
Tuple2.swap = (tuple) => [tuple[1], tuple[0]];
|
|
2470
|
-
let to;
|
|
2471
|
-
((to2) => {
|
|
2472
|
-
to2.Array = (tuple) => [...tuple];
|
|
2473
|
-
})(to = Tuple2.to || (Tuple2.to = {}));
|
|
2474
|
-
Tuple2.tap = (f) => (tuple) => {
|
|
2475
|
-
f(tuple[0], tuple[1]);
|
|
2476
|
-
return tuple;
|
|
2477
|
-
};
|
|
2478
|
-
})(Tuple || (Tuple = {}));
|
|
2479
|
-
|
|
2480
2491
|
// src/Core/Validation.ts
|
|
2481
2492
|
var Validation;
|
|
2482
2493
|
((Validation2) => {
|
|
@@ -2594,6 +2605,7 @@ export {
|
|
|
2594
2605
|
Op,
|
|
2595
2606
|
Optional,
|
|
2596
2607
|
Ordering,
|
|
2608
|
+
Pair,
|
|
2597
2609
|
Predicate,
|
|
2598
2610
|
Reader,
|
|
2599
2611
|
Refinement,
|
|
@@ -2605,6 +2617,5 @@ export {
|
|
|
2605
2617
|
isNonEmptyArr,
|
|
2606
2618
|
Task,
|
|
2607
2619
|
These,
|
|
2608
|
-
Tuple,
|
|
2609
2620
|
Validation
|
|
2610
2621
|
};
|
package/dist/core.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(Core_exports, {
|
|
|
30
30
|
Op: () => Op,
|
|
31
31
|
Optional: () => Optional,
|
|
32
32
|
Ordering: () => Ordering,
|
|
33
|
+
Pair: () => Pair,
|
|
33
34
|
Predicate: () => Predicate,
|
|
34
35
|
Reader: () => Reader,
|
|
35
36
|
Refinement: () => Refinement,
|
|
@@ -40,7 +41,6 @@ __export(Core_exports, {
|
|
|
40
41
|
Stream: () => Stream,
|
|
41
42
|
Task: () => Task,
|
|
42
43
|
These: () => These,
|
|
43
|
-
Tuple: () => Tuple,
|
|
44
44
|
Validation: () => Validation
|
|
45
45
|
});
|
|
46
46
|
module.exports = __toCommonJS(Core_exports);
|
|
@@ -1473,6 +1473,34 @@ var Ordering;
|
|
|
1473
1473
|
};
|
|
1474
1474
|
})(Ordering || (Ordering = {}));
|
|
1475
1475
|
|
|
1476
|
+
// src/Core/Pair.ts
|
|
1477
|
+
var Pair;
|
|
1478
|
+
((Pair2) => {
|
|
1479
|
+
let from;
|
|
1480
|
+
((from2) => {
|
|
1481
|
+
from2.pair = (first2, second2) => [first2, second2];
|
|
1482
|
+
from2.array = (arr) => arr;
|
|
1483
|
+
})(from = Pair2.from || (Pair2.from = {}));
|
|
1484
|
+
Pair2.first = (p) => p[0];
|
|
1485
|
+
Pair2.second = (p) => p[1];
|
|
1486
|
+
Pair2.mapFirst = (f) => (p) => [f(p[0]), p[1]];
|
|
1487
|
+
Pair2.mapSecond = (f) => (p) => [p[0], f(p[1])];
|
|
1488
|
+
Pair2.mapBoth = (onFirst, onSecond) => (p) => [
|
|
1489
|
+
onFirst(p[0]),
|
|
1490
|
+
onSecond(p[1])
|
|
1491
|
+
];
|
|
1492
|
+
Pair2.fold = (f) => (p) => f(p[0], p[1]);
|
|
1493
|
+
Pair2.swap = (p) => [p[1], p[0]];
|
|
1494
|
+
let to;
|
|
1495
|
+
((to2) => {
|
|
1496
|
+
to2.Array = (p) => [...p];
|
|
1497
|
+
})(to = Pair2.to || (Pair2.to = {}));
|
|
1498
|
+
Pair2.tap = (f) => (p) => {
|
|
1499
|
+
f(p[0], p[1]);
|
|
1500
|
+
return p;
|
|
1501
|
+
};
|
|
1502
|
+
})(Pair || (Pair = {}));
|
|
1503
|
+
|
|
1476
1504
|
// src/Core/Predicate.ts
|
|
1477
1505
|
var Predicate;
|
|
1478
1506
|
((Predicate2) => {
|
|
@@ -2022,6 +2050,9 @@ var TaskResult;
|
|
|
2022
2050
|
TaskResult2.recover = (fallback) => (data) => Task.chain(
|
|
2023
2051
|
(result) => Result.is.err(result) ? fallback(result.error) : Task.resolve(result)
|
|
2024
2052
|
)(data);
|
|
2053
|
+
TaskResult2.recoverUnless = (isBlocked, fallback) => (data) => Task.chain(
|
|
2054
|
+
(result) => Result.is.err(result) && !isBlocked(result.error) ? fallback(result.error) : Task.resolve(result)
|
|
2055
|
+
)(data);
|
|
2025
2056
|
TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
|
|
2026
2057
|
TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
|
|
2027
2058
|
TaskResult2.tapError = (f) => (data) => Task.map(Result.tapError(f))(data);
|
|
@@ -2132,6 +2163,11 @@ var TaskValidation;
|
|
|
2132
2163
|
);
|
|
2133
2164
|
from2.Result = (result) => Task.resolve(Validation.from.Result(result));
|
|
2134
2165
|
})(from = TaskValidation2.from || (TaskValidation2.from = {}));
|
|
2166
|
+
let to;
|
|
2167
|
+
((to2) => {
|
|
2168
|
+
to2.Result = (combineErrors) => (data) => Task.map(Validation.to.Result(combineErrors))(data);
|
|
2169
|
+
to2.Maybe = (data) => Task.map(Validation.to.Maybe)(data);
|
|
2170
|
+
})(to = TaskValidation2.to || (TaskValidation2.to = {}));
|
|
2135
2171
|
TaskValidation2.tryCatch = (f, options) => (signal) => Deferred.from.Promise(
|
|
2136
2172
|
globalThis.Promise.resolve().then(async () => f(signal)).then(Validation.make.passed).catch(
|
|
2137
2173
|
(error) => Validation.make.failed(options.onError(error))
|
|
@@ -2150,6 +2186,9 @@ var TaskValidation;
|
|
|
2150
2186
|
TaskValidation2.recover = (fallback) => (data) => Task.chain(
|
|
2151
2187
|
(validation) => Validation.is.passed(validation) ? Task.resolve(validation) : fallback(validation.errors)
|
|
2152
2188
|
)(data);
|
|
2189
|
+
TaskValidation2.recoverUnless = (isBlocked, fallback) => (data) => Task.chain(
|
|
2190
|
+
(validation) => Validation.is.passed(validation) ? Task.resolve(validation) : isBlocked(validation.errors) ? Task.resolve(validation) : fallback(validation.errors)
|
|
2191
|
+
)(data);
|
|
2153
2192
|
TaskValidation2.product = (first, second) => (signal) => Deferred.from.Promise(
|
|
2154
2193
|
Promise.all([Deferred.to.Promise(first(signal)), Deferred.to.Promise(second(signal))]).then(
|
|
2155
2194
|
([va, vb]) => Validation.product(va, vb)
|
|
@@ -2520,34 +2559,6 @@ var These;
|
|
|
2520
2559
|
};
|
|
2521
2560
|
})(These || (These = {}));
|
|
2522
2561
|
|
|
2523
|
-
// src/Core/Tuple.ts
|
|
2524
|
-
var Tuple;
|
|
2525
|
-
((Tuple2) => {
|
|
2526
|
-
let from;
|
|
2527
|
-
((from2) => {
|
|
2528
|
-
from2.pair = (first2, second2) => [first2, second2];
|
|
2529
|
-
from2.array = (arr) => arr;
|
|
2530
|
-
})(from = Tuple2.from || (Tuple2.from = {}));
|
|
2531
|
-
Tuple2.first = (tuple) => tuple[0];
|
|
2532
|
-
Tuple2.second = (tuple) => tuple[1];
|
|
2533
|
-
Tuple2.mapFirst = (f) => (tuple) => [f(tuple[0]), tuple[1]];
|
|
2534
|
-
Tuple2.mapSecond = (f) => (tuple) => [tuple[0], f(tuple[1])];
|
|
2535
|
-
Tuple2.mapBoth = (onFirst, onSecond) => (tuple) => [
|
|
2536
|
-
onFirst(tuple[0]),
|
|
2537
|
-
onSecond(tuple[1])
|
|
2538
|
-
];
|
|
2539
|
-
Tuple2.fold = (f) => (tuple) => f(tuple[0], tuple[1]);
|
|
2540
|
-
Tuple2.swap = (tuple) => [tuple[1], tuple[0]];
|
|
2541
|
-
let to;
|
|
2542
|
-
((to2) => {
|
|
2543
|
-
to2.Array = (tuple) => [...tuple];
|
|
2544
|
-
})(to = Tuple2.to || (Tuple2.to = {}));
|
|
2545
|
-
Tuple2.tap = (f) => (tuple) => {
|
|
2546
|
-
f(tuple[0], tuple[1]);
|
|
2547
|
-
return tuple;
|
|
2548
|
-
};
|
|
2549
|
-
})(Tuple || (Tuple = {}));
|
|
2550
|
-
|
|
2551
2562
|
// src/Core/Validation.ts
|
|
2552
2563
|
var Validation;
|
|
2553
2564
|
((Validation2) => {
|
|
@@ -2665,6 +2676,7 @@ var Validation;
|
|
|
2665
2676
|
Op,
|
|
2666
2677
|
Optional,
|
|
2667
2678
|
Ordering,
|
|
2679
|
+
Pair,
|
|
2668
2680
|
Predicate,
|
|
2669
2681
|
Reader,
|
|
2670
2682
|
Refinement,
|
|
@@ -2675,6 +2687,5 @@ var Validation;
|
|
|
2675
2687
|
Stream,
|
|
2676
2688
|
Task,
|
|
2677
2689
|
These,
|
|
2678
|
-
Tuple,
|
|
2679
2690
|
Validation
|
|
2680
2691
|
});
|
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Maybe, R as Result, T as Task } from './Validation-
|
|
2
|
-
export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Validation-
|
|
1
|
+
import { M as Maybe, R as Result, T as Task } from './Validation-DC3uUizM.cjs';
|
|
2
|
+
export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Validation-DC3uUizM.cjs';
|
|
3
3
|
import { o as WithValue, i as WithLog, D as Deferred, h as WithKind, e as WithError, R as RetryOptions, b as TimeoutOptions, n as WithTimeout, j as WithMinInterval, c as WithCooldown, W as WithConcurrency, m as WithSize, d as WithDuration, k as WithN, g as WithFirst, l as WithSecond } from './InternalTypes-DuK_XpTi.cjs';
|
|
4
4
|
import { D as Duration } from './Duration-B8joKzro.cjs';
|
|
5
5
|
import './types.cjs';
|
|
@@ -1327,6 +1327,148 @@ declare namespace Optional {
|
|
|
1327
1327
|
const andThenLens: <A, B>(inner: Lens<A, B>) => <S>(outer: Optional<S, A>) => Optional<S, B>;
|
|
1328
1328
|
}
|
|
1329
1329
|
|
|
1330
|
+
/**
|
|
1331
|
+
* Pair<A, B> represents a pair of two values that are always both present.
|
|
1332
|
+
* It is a typed alias for `readonly [A, B]`.
|
|
1333
|
+
*
|
|
1334
|
+
* Use Pair when two values always travel together through a pipeline and you
|
|
1335
|
+
* want to transform either or both sides without destructuring.
|
|
1336
|
+
*
|
|
1337
|
+
* @example
|
|
1338
|
+
* ```ts
|
|
1339
|
+
* import { Pair } from "@nlozgachev/pipelined/core";
|
|
1340
|
+
* import { pipe } from "@nlozgachev/pipelined/composition";
|
|
1341
|
+
*
|
|
1342
|
+
* const entry = Pair.from.pair("alice", 42);
|
|
1343
|
+
*
|
|
1344
|
+
* pipe(
|
|
1345
|
+
* entry,
|
|
1346
|
+
* Pair.mapFirst((name) => name.toUpperCase()),
|
|
1347
|
+
* Pair.mapSecond((score) => score * 2),
|
|
1348
|
+
* Pair.fold((name, score) => `${name}: ${score}`),
|
|
1349
|
+
* ); // "ALICE: 84"
|
|
1350
|
+
* ```
|
|
1351
|
+
*/
|
|
1352
|
+
type Pair<A, B> = readonly [A, B];
|
|
1353
|
+
declare namespace Pair {
|
|
1354
|
+
namespace from {
|
|
1355
|
+
/**
|
|
1356
|
+
* Creates a Pair from two values.
|
|
1357
|
+
*
|
|
1358
|
+
* @example
|
|
1359
|
+
* ```ts
|
|
1360
|
+
* Pair.from.pair("Paris", 2_161_000); // ["Paris", 2161000]
|
|
1361
|
+
* ```
|
|
1362
|
+
*/
|
|
1363
|
+
const pair: <A, B>(first: A, second: B) => Pair<A, B>;
|
|
1364
|
+
/**
|
|
1365
|
+
* Creates a Pair from a two-element array.
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* ```ts
|
|
1369
|
+
* Pair.from.array(["Paris", 2_161_000] as const); // ["Paris", 2161000]
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
const array: <A, B>(arr: readonly [A, B]) => Pair<A, B>;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Returns the first value from the pair.
|
|
1376
|
+
*
|
|
1377
|
+
* @example
|
|
1378
|
+
* ```ts
|
|
1379
|
+
* Pair.first(Pair.from.pair("Paris", 2_161_000)); // "Paris"
|
|
1380
|
+
* ```
|
|
1381
|
+
*/
|
|
1382
|
+
const first: <A, B>(p: Pair<A, B>) => A;
|
|
1383
|
+
/**
|
|
1384
|
+
* Returns the second value from the pair.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* Pair.second(Pair.from.pair("Paris", 2_161_000)); // 2161000
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1391
|
+
const second: <A, B>(p: Pair<A, B>) => B;
|
|
1392
|
+
/**
|
|
1393
|
+
* Transforms the first value, leaving the second unchanged.
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```ts
|
|
1397
|
+
* pipe(Pair.from.pair("alice", 42), Pair.mapFirst((s) => s.toUpperCase())); // ["ALICE", 42]
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
const mapFirst: <A, C>(f: (a: A) => C) => <B>(p: Pair<A, B>) => Pair<C, B>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Transforms the second value, leaving the first unchanged.
|
|
1403
|
+
*
|
|
1404
|
+
* @example
|
|
1405
|
+
* ```ts
|
|
1406
|
+
* pipe(Pair.from.pair("alice", 42), Pair.mapSecond((n) => n * 2)); // ["alice", 84]
|
|
1407
|
+
* ```
|
|
1408
|
+
*/
|
|
1409
|
+
const mapSecond: <B, D>(f: (b: B) => D) => <A>(p: Pair<A, B>) => Pair<A, D>;
|
|
1410
|
+
/**
|
|
1411
|
+
* Transforms both values independently in a single step.
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```ts
|
|
1415
|
+
* pipe(
|
|
1416
|
+
* Pair.from.pair("alice", 42),
|
|
1417
|
+
* Pair.mapBoth(
|
|
1418
|
+
* (name) => name.toUpperCase(),
|
|
1419
|
+
* (score) => score * 2,
|
|
1420
|
+
* ),
|
|
1421
|
+
* ); // ["ALICE", 84]
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
const mapBoth: <A, C, B, D>(onFirst: (a: A) => C, onSecond: (b: B) => D) => (p: Pair<A, B>) => Pair<C, D>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Applies a binary function to both values, collapsing the pair into a single value.
|
|
1427
|
+
* Useful as the final step when consuming a pair in a pipeline.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```ts
|
|
1431
|
+
* pipe(Pair.from.pair("Alice", 100), Pair.fold((name, score) => `${name}: ${score}`));
|
|
1432
|
+
* // "Alice: 100"
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
const fold: <A, B, C>(f: (a: A, b: B) => C) => (p: Pair<A, B>) => C;
|
|
1436
|
+
/**
|
|
1437
|
+
* Swaps the two values: `[A, B]` becomes `[B, A]`.
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* Pair.swap(Pair.from.pair("key", 1)); // [1, "key"]
|
|
1442
|
+
* ```
|
|
1443
|
+
*/
|
|
1444
|
+
const swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
|
|
1445
|
+
namespace to {
|
|
1446
|
+
/**
|
|
1447
|
+
* Converts the pair to a heterogeneous readonly array `readonly (A | B)[]`.
|
|
1448
|
+
*
|
|
1449
|
+
* @example
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* Pair.to.Array(Pair.from.pair("hello", 42)); // ["hello", 42]
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
1454
|
+
const Array: <A, B>(p: Pair<A, B>) => readonly (A | B)[];
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Runs a side effect with both values without changing the pair.
|
|
1458
|
+
* Useful for logging or debugging in the middle of a pipeline.
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* ```ts
|
|
1462
|
+
* pipe(
|
|
1463
|
+
* Pair.from.pair("Paris", 2_161_000),
|
|
1464
|
+
* Pair.tap((city, pop) => console.log(`${city}: ${pop}`)),
|
|
1465
|
+
* Pair.mapSecond((n) => n / 1_000_000),
|
|
1466
|
+
* ); // logs "Paris: 2161000", returns ["Paris", 2.161]
|
|
1467
|
+
* ```
|
|
1468
|
+
*/
|
|
1469
|
+
const tap: <A, B>(f: (a: A, b: B) => void) => (p: Pair<A, B>) => Pair<A, B>;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1330
1472
|
/**
|
|
1331
1473
|
* A boolean-valued function over a type `A`.
|
|
1332
1474
|
*
|
|
@@ -2877,146 +3019,4 @@ declare namespace These {
|
|
|
2877
3019
|
const swap: <A, B>(data: These<A, B>) => These<B, A>;
|
|
2878
3020
|
}
|
|
2879
3021
|
|
|
2880
|
-
|
|
2881
|
-
* Tuple<A, B> represents a pair of two values that are always both present.
|
|
2882
|
-
* It is a typed alias for `readonly [A, B]`.
|
|
2883
|
-
*
|
|
2884
|
-
* Use Tuple when two values always travel together through a pipeline and you
|
|
2885
|
-
* want to transform either or both sides without destructuring.
|
|
2886
|
-
*
|
|
2887
|
-
* @example
|
|
2888
|
-
* ```ts
|
|
2889
|
-
* import { Tuple } from "@nlozgachev/pipelined/core";
|
|
2890
|
-
* import { pipe } from "@nlozgachev/pipelined/composition";
|
|
2891
|
-
*
|
|
2892
|
-
* const entry = Tuple.from.pair("alice", 42);
|
|
2893
|
-
*
|
|
2894
|
-
* pipe(
|
|
2895
|
-
* entry,
|
|
2896
|
-
* Tuple.mapFirst((name) => name.toUpperCase()),
|
|
2897
|
-
* Tuple.mapSecond((score) => score * 2),
|
|
2898
|
-
* Tuple.fold((name, score) => `${name}: ${score}`),
|
|
2899
|
-
* ); // "ALICE: 84"
|
|
2900
|
-
* ```
|
|
2901
|
-
*/
|
|
2902
|
-
type Tuple<A, B> = readonly [A, B];
|
|
2903
|
-
declare namespace Tuple {
|
|
2904
|
-
namespace from {
|
|
2905
|
-
/**
|
|
2906
|
-
* Creates a pair from two values.
|
|
2907
|
-
*
|
|
2908
|
-
* @example
|
|
2909
|
-
* ```ts
|
|
2910
|
-
* Tuple.from.pair("Paris", 2_161_000); // ["Paris", 2161000]
|
|
2911
|
-
* ```
|
|
2912
|
-
*/
|
|
2913
|
-
const pair: <A, B>(first: A, second: B) => Tuple<A, B>;
|
|
2914
|
-
/**
|
|
2915
|
-
* Creates a Tuple from a two-element array.
|
|
2916
|
-
*
|
|
2917
|
-
* @example
|
|
2918
|
-
* ```ts
|
|
2919
|
-
* Tuple.from.array(["Paris", 2_161_000] as const); // ["Paris", 2161000]
|
|
2920
|
-
* ```
|
|
2921
|
-
*/
|
|
2922
|
-
const array: <A, B>(arr: readonly [A, B]) => Tuple<A, B>;
|
|
2923
|
-
}
|
|
2924
|
-
/**
|
|
2925
|
-
* Returns the first value from the pair.
|
|
2926
|
-
*
|
|
2927
|
-
* @example
|
|
2928
|
-
* ```ts
|
|
2929
|
-
* Tuple.first(Tuple.from.pair("Paris", 2_161_000)); // "Paris"
|
|
2930
|
-
* ```
|
|
2931
|
-
*/
|
|
2932
|
-
const first: <A, B>(tuple: Tuple<A, B>) => A;
|
|
2933
|
-
/**
|
|
2934
|
-
* Returns the second value from the pair.
|
|
2935
|
-
*
|
|
2936
|
-
* @example
|
|
2937
|
-
* ```ts
|
|
2938
|
-
* Tuple.second(Tuple.from.pair("Paris", 2_161_000)); // 2161000
|
|
2939
|
-
* ```
|
|
2940
|
-
*/
|
|
2941
|
-
const second: <A, B>(tuple: Tuple<A, B>) => B;
|
|
2942
|
-
/**
|
|
2943
|
-
* Transforms the first value, leaving the second unchanged.
|
|
2944
|
-
*
|
|
2945
|
-
* @example
|
|
2946
|
-
* ```ts
|
|
2947
|
-
* pipe(Tuple.from.pair("alice", 42), Tuple.mapFirst((s) => s.toUpperCase())); // ["ALICE", 42]
|
|
2948
|
-
* ```
|
|
2949
|
-
*/
|
|
2950
|
-
const mapFirst: <A, C>(f: (a: A) => C) => <B>(tuple: Tuple<A, B>) => Tuple<C, B>;
|
|
2951
|
-
/**
|
|
2952
|
-
* Transforms the second value, leaving the first unchanged.
|
|
2953
|
-
*
|
|
2954
|
-
* @example
|
|
2955
|
-
* ```ts
|
|
2956
|
-
* pipe(Tuple.from.pair("alice", 42), Tuple.mapSecond((n) => n * 2)); // ["alice", 84]
|
|
2957
|
-
* ```
|
|
2958
|
-
*/
|
|
2959
|
-
const mapSecond: <B, D>(f: (b: B) => D) => <A>(tuple: Tuple<A, B>) => Tuple<A, D>;
|
|
2960
|
-
/**
|
|
2961
|
-
* Transforms both values independently in a single step.
|
|
2962
|
-
*
|
|
2963
|
-
* @example
|
|
2964
|
-
* ```ts
|
|
2965
|
-
* pipe(
|
|
2966
|
-
* Tuple.from.pair("alice", 42),
|
|
2967
|
-
* Tuple.mapBoth(
|
|
2968
|
-
* (name) => name.toUpperCase(),
|
|
2969
|
-
* (score) => score * 2,
|
|
2970
|
-
* ),
|
|
2971
|
-
* ); // ["ALICE", 84]
|
|
2972
|
-
* ```
|
|
2973
|
-
*/
|
|
2974
|
-
const mapBoth: <A, C, B, D>(onFirst: (a: A) => C, onSecond: (b: B) => D) => (tuple: Tuple<A, B>) => Tuple<C, D>;
|
|
2975
|
-
/**
|
|
2976
|
-
* Applies a binary function to both values, collapsing the pair into a single value.
|
|
2977
|
-
* Useful as the final step when consuming a pair in a pipeline.
|
|
2978
|
-
*
|
|
2979
|
-
* @example
|
|
2980
|
-
* ```ts
|
|
2981
|
-
* pipe(Tuple.from.pair("Alice", 100), Tuple.fold((name, score) => `${name}: ${score}`));
|
|
2982
|
-
* // "Alice: 100"
|
|
2983
|
-
* ```
|
|
2984
|
-
*/
|
|
2985
|
-
const fold: <A, B, C>(f: (a: A, b: B) => C) => (tuple: Tuple<A, B>) => C;
|
|
2986
|
-
/**
|
|
2987
|
-
* Swaps the two values: `[A, B]` becomes `[B, A]`.
|
|
2988
|
-
*
|
|
2989
|
-
* @example
|
|
2990
|
-
* ```ts
|
|
2991
|
-
* Tuple.swap(Tuple.from.pair("key", 1)); // [1, "key"]
|
|
2992
|
-
* ```
|
|
2993
|
-
*/
|
|
2994
|
-
const swap: <A, B>(tuple: Tuple<A, B>) => Tuple<B, A>;
|
|
2995
|
-
namespace to {
|
|
2996
|
-
/**
|
|
2997
|
-
* Converts the pair to a heterogeneous readonly array `readonly (A | B)[]`.
|
|
2998
|
-
*
|
|
2999
|
-
* @example
|
|
3000
|
-
* ```ts
|
|
3001
|
-
* Tuple.to.Array(Tuple.from.pair("hello", 42)); // ["hello", 42]
|
|
3002
|
-
* ```
|
|
3003
|
-
*/
|
|
3004
|
-
const Array: <A, B>(tuple: Tuple<A, B>) => readonly (A | B)[];
|
|
3005
|
-
}
|
|
3006
|
-
/**
|
|
3007
|
-
* Runs a side effect with both values without changing the pair.
|
|
3008
|
-
* Useful for logging or debugging in the middle of a pipeline.
|
|
3009
|
-
*
|
|
3010
|
-
* @example
|
|
3011
|
-
* ```ts
|
|
3012
|
-
* pipe(
|
|
3013
|
-
* Tuple.from.pair("Paris", 2_161_000),
|
|
3014
|
-
* Tuple.tap((city, pop) => console.log(`${city}: ${pop}`)),
|
|
3015
|
-
* Tuple.mapSecond((n) => n / 1_000_000),
|
|
3016
|
-
* ); // logs "Paris: 2161000", returns ["Paris", 2.161]
|
|
3017
|
-
* ```
|
|
3018
|
-
*/
|
|
3019
|
-
const tap: <A, B>(f: (a: A, b: B) => void) => (tuple: Tuple<A, B>) => Tuple<A, B>;
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
export { Combinable, Deferred, type Failure, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, Stream, type Success, Task, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple };
|
|
3022
|
+
export { Combinable, Deferred, type Failure, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Pair, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, Stream, type Success, Task, These, type TheseBoth, type TheseFirst, type TheseSecond };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Maybe, R as Result, T as Task } from './Validation-
|
|
2
|
-
export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Validation-
|
|
1
|
+
import { M as Maybe, R as Result, T as Task } from './Validation-DZLizBZ0.js';
|
|
2
|
+
export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Validation-DZLizBZ0.js';
|
|
3
3
|
import { o as WithValue, i as WithLog, D as Deferred, h as WithKind, e as WithError, R as RetryOptions, b as TimeoutOptions, n as WithTimeout, j as WithMinInterval, c as WithCooldown, W as WithConcurrency, m as WithSize, d as WithDuration, k as WithN, g as WithFirst, l as WithSecond } from './InternalTypes-LdhLQx3N.js';
|
|
4
4
|
import { D as Duration } from './Duration-B8joKzro.js';
|
|
5
5
|
import './types.js';
|
|
@@ -1327,6 +1327,148 @@ declare namespace Optional {
|
|
|
1327
1327
|
const andThenLens: <A, B>(inner: Lens<A, B>) => <S>(outer: Optional<S, A>) => Optional<S, B>;
|
|
1328
1328
|
}
|
|
1329
1329
|
|
|
1330
|
+
/**
|
|
1331
|
+
* Pair<A, B> represents a pair of two values that are always both present.
|
|
1332
|
+
* It is a typed alias for `readonly [A, B]`.
|
|
1333
|
+
*
|
|
1334
|
+
* Use Pair when two values always travel together through a pipeline and you
|
|
1335
|
+
* want to transform either or both sides without destructuring.
|
|
1336
|
+
*
|
|
1337
|
+
* @example
|
|
1338
|
+
* ```ts
|
|
1339
|
+
* import { Pair } from "@nlozgachev/pipelined/core";
|
|
1340
|
+
* import { pipe } from "@nlozgachev/pipelined/composition";
|
|
1341
|
+
*
|
|
1342
|
+
* const entry = Pair.from.pair("alice", 42);
|
|
1343
|
+
*
|
|
1344
|
+
* pipe(
|
|
1345
|
+
* entry,
|
|
1346
|
+
* Pair.mapFirst((name) => name.toUpperCase()),
|
|
1347
|
+
* Pair.mapSecond((score) => score * 2),
|
|
1348
|
+
* Pair.fold((name, score) => `${name}: ${score}`),
|
|
1349
|
+
* ); // "ALICE: 84"
|
|
1350
|
+
* ```
|
|
1351
|
+
*/
|
|
1352
|
+
type Pair<A, B> = readonly [A, B];
|
|
1353
|
+
declare namespace Pair {
|
|
1354
|
+
namespace from {
|
|
1355
|
+
/**
|
|
1356
|
+
* Creates a Pair from two values.
|
|
1357
|
+
*
|
|
1358
|
+
* @example
|
|
1359
|
+
* ```ts
|
|
1360
|
+
* Pair.from.pair("Paris", 2_161_000); // ["Paris", 2161000]
|
|
1361
|
+
* ```
|
|
1362
|
+
*/
|
|
1363
|
+
const pair: <A, B>(first: A, second: B) => Pair<A, B>;
|
|
1364
|
+
/**
|
|
1365
|
+
* Creates a Pair from a two-element array.
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* ```ts
|
|
1369
|
+
* Pair.from.array(["Paris", 2_161_000] as const); // ["Paris", 2161000]
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
const array: <A, B>(arr: readonly [A, B]) => Pair<A, B>;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Returns the first value from the pair.
|
|
1376
|
+
*
|
|
1377
|
+
* @example
|
|
1378
|
+
* ```ts
|
|
1379
|
+
* Pair.first(Pair.from.pair("Paris", 2_161_000)); // "Paris"
|
|
1380
|
+
* ```
|
|
1381
|
+
*/
|
|
1382
|
+
const first: <A, B>(p: Pair<A, B>) => A;
|
|
1383
|
+
/**
|
|
1384
|
+
* Returns the second value from the pair.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* Pair.second(Pair.from.pair("Paris", 2_161_000)); // 2161000
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1391
|
+
const second: <A, B>(p: Pair<A, B>) => B;
|
|
1392
|
+
/**
|
|
1393
|
+
* Transforms the first value, leaving the second unchanged.
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```ts
|
|
1397
|
+
* pipe(Pair.from.pair("alice", 42), Pair.mapFirst((s) => s.toUpperCase())); // ["ALICE", 42]
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
const mapFirst: <A, C>(f: (a: A) => C) => <B>(p: Pair<A, B>) => Pair<C, B>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Transforms the second value, leaving the first unchanged.
|
|
1403
|
+
*
|
|
1404
|
+
* @example
|
|
1405
|
+
* ```ts
|
|
1406
|
+
* pipe(Pair.from.pair("alice", 42), Pair.mapSecond((n) => n * 2)); // ["alice", 84]
|
|
1407
|
+
* ```
|
|
1408
|
+
*/
|
|
1409
|
+
const mapSecond: <B, D>(f: (b: B) => D) => <A>(p: Pair<A, B>) => Pair<A, D>;
|
|
1410
|
+
/**
|
|
1411
|
+
* Transforms both values independently in a single step.
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```ts
|
|
1415
|
+
* pipe(
|
|
1416
|
+
* Pair.from.pair("alice", 42),
|
|
1417
|
+
* Pair.mapBoth(
|
|
1418
|
+
* (name) => name.toUpperCase(),
|
|
1419
|
+
* (score) => score * 2,
|
|
1420
|
+
* ),
|
|
1421
|
+
* ); // ["ALICE", 84]
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
const mapBoth: <A, C, B, D>(onFirst: (a: A) => C, onSecond: (b: B) => D) => (p: Pair<A, B>) => Pair<C, D>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Applies a binary function to both values, collapsing the pair into a single value.
|
|
1427
|
+
* Useful as the final step when consuming a pair in a pipeline.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```ts
|
|
1431
|
+
* pipe(Pair.from.pair("Alice", 100), Pair.fold((name, score) => `${name}: ${score}`));
|
|
1432
|
+
* // "Alice: 100"
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
const fold: <A, B, C>(f: (a: A, b: B) => C) => (p: Pair<A, B>) => C;
|
|
1436
|
+
/**
|
|
1437
|
+
* Swaps the two values: `[A, B]` becomes `[B, A]`.
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* Pair.swap(Pair.from.pair("key", 1)); // [1, "key"]
|
|
1442
|
+
* ```
|
|
1443
|
+
*/
|
|
1444
|
+
const swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
|
|
1445
|
+
namespace to {
|
|
1446
|
+
/**
|
|
1447
|
+
* Converts the pair to a heterogeneous readonly array `readonly (A | B)[]`.
|
|
1448
|
+
*
|
|
1449
|
+
* @example
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* Pair.to.Array(Pair.from.pair("hello", 42)); // ["hello", 42]
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
1454
|
+
const Array: <A, B>(p: Pair<A, B>) => readonly (A | B)[];
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Runs a side effect with both values without changing the pair.
|
|
1458
|
+
* Useful for logging or debugging in the middle of a pipeline.
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* ```ts
|
|
1462
|
+
* pipe(
|
|
1463
|
+
* Pair.from.pair("Paris", 2_161_000),
|
|
1464
|
+
* Pair.tap((city, pop) => console.log(`${city}: ${pop}`)),
|
|
1465
|
+
* Pair.mapSecond((n) => n / 1_000_000),
|
|
1466
|
+
* ); // logs "Paris: 2161000", returns ["Paris", 2.161]
|
|
1467
|
+
* ```
|
|
1468
|
+
*/
|
|
1469
|
+
const tap: <A, B>(f: (a: A, b: B) => void) => (p: Pair<A, B>) => Pair<A, B>;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1330
1472
|
/**
|
|
1331
1473
|
* A boolean-valued function over a type `A`.
|
|
1332
1474
|
*
|
|
@@ -2877,146 +3019,4 @@ declare namespace These {
|
|
|
2877
3019
|
const swap: <A, B>(data: These<A, B>) => These<B, A>;
|
|
2878
3020
|
}
|
|
2879
3021
|
|
|
2880
|
-
|
|
2881
|
-
* Tuple<A, B> represents a pair of two values that are always both present.
|
|
2882
|
-
* It is a typed alias for `readonly [A, B]`.
|
|
2883
|
-
*
|
|
2884
|
-
* Use Tuple when two values always travel together through a pipeline and you
|
|
2885
|
-
* want to transform either or both sides without destructuring.
|
|
2886
|
-
*
|
|
2887
|
-
* @example
|
|
2888
|
-
* ```ts
|
|
2889
|
-
* import { Tuple } from "@nlozgachev/pipelined/core";
|
|
2890
|
-
* import { pipe } from "@nlozgachev/pipelined/composition";
|
|
2891
|
-
*
|
|
2892
|
-
* const entry = Tuple.from.pair("alice", 42);
|
|
2893
|
-
*
|
|
2894
|
-
* pipe(
|
|
2895
|
-
* entry,
|
|
2896
|
-
* Tuple.mapFirst((name) => name.toUpperCase()),
|
|
2897
|
-
* Tuple.mapSecond((score) => score * 2),
|
|
2898
|
-
* Tuple.fold((name, score) => `${name}: ${score}`),
|
|
2899
|
-
* ); // "ALICE: 84"
|
|
2900
|
-
* ```
|
|
2901
|
-
*/
|
|
2902
|
-
type Tuple<A, B> = readonly [A, B];
|
|
2903
|
-
declare namespace Tuple {
|
|
2904
|
-
namespace from {
|
|
2905
|
-
/**
|
|
2906
|
-
* Creates a pair from two values.
|
|
2907
|
-
*
|
|
2908
|
-
* @example
|
|
2909
|
-
* ```ts
|
|
2910
|
-
* Tuple.from.pair("Paris", 2_161_000); // ["Paris", 2161000]
|
|
2911
|
-
* ```
|
|
2912
|
-
*/
|
|
2913
|
-
const pair: <A, B>(first: A, second: B) => Tuple<A, B>;
|
|
2914
|
-
/**
|
|
2915
|
-
* Creates a Tuple from a two-element array.
|
|
2916
|
-
*
|
|
2917
|
-
* @example
|
|
2918
|
-
* ```ts
|
|
2919
|
-
* Tuple.from.array(["Paris", 2_161_000] as const); // ["Paris", 2161000]
|
|
2920
|
-
* ```
|
|
2921
|
-
*/
|
|
2922
|
-
const array: <A, B>(arr: readonly [A, B]) => Tuple<A, B>;
|
|
2923
|
-
}
|
|
2924
|
-
/**
|
|
2925
|
-
* Returns the first value from the pair.
|
|
2926
|
-
*
|
|
2927
|
-
* @example
|
|
2928
|
-
* ```ts
|
|
2929
|
-
* Tuple.first(Tuple.from.pair("Paris", 2_161_000)); // "Paris"
|
|
2930
|
-
* ```
|
|
2931
|
-
*/
|
|
2932
|
-
const first: <A, B>(tuple: Tuple<A, B>) => A;
|
|
2933
|
-
/**
|
|
2934
|
-
* Returns the second value from the pair.
|
|
2935
|
-
*
|
|
2936
|
-
* @example
|
|
2937
|
-
* ```ts
|
|
2938
|
-
* Tuple.second(Tuple.from.pair("Paris", 2_161_000)); // 2161000
|
|
2939
|
-
* ```
|
|
2940
|
-
*/
|
|
2941
|
-
const second: <A, B>(tuple: Tuple<A, B>) => B;
|
|
2942
|
-
/**
|
|
2943
|
-
* Transforms the first value, leaving the second unchanged.
|
|
2944
|
-
*
|
|
2945
|
-
* @example
|
|
2946
|
-
* ```ts
|
|
2947
|
-
* pipe(Tuple.from.pair("alice", 42), Tuple.mapFirst((s) => s.toUpperCase())); // ["ALICE", 42]
|
|
2948
|
-
* ```
|
|
2949
|
-
*/
|
|
2950
|
-
const mapFirst: <A, C>(f: (a: A) => C) => <B>(tuple: Tuple<A, B>) => Tuple<C, B>;
|
|
2951
|
-
/**
|
|
2952
|
-
* Transforms the second value, leaving the first unchanged.
|
|
2953
|
-
*
|
|
2954
|
-
* @example
|
|
2955
|
-
* ```ts
|
|
2956
|
-
* pipe(Tuple.from.pair("alice", 42), Tuple.mapSecond((n) => n * 2)); // ["alice", 84]
|
|
2957
|
-
* ```
|
|
2958
|
-
*/
|
|
2959
|
-
const mapSecond: <B, D>(f: (b: B) => D) => <A>(tuple: Tuple<A, B>) => Tuple<A, D>;
|
|
2960
|
-
/**
|
|
2961
|
-
* Transforms both values independently in a single step.
|
|
2962
|
-
*
|
|
2963
|
-
* @example
|
|
2964
|
-
* ```ts
|
|
2965
|
-
* pipe(
|
|
2966
|
-
* Tuple.from.pair("alice", 42),
|
|
2967
|
-
* Tuple.mapBoth(
|
|
2968
|
-
* (name) => name.toUpperCase(),
|
|
2969
|
-
* (score) => score * 2,
|
|
2970
|
-
* ),
|
|
2971
|
-
* ); // ["ALICE", 84]
|
|
2972
|
-
* ```
|
|
2973
|
-
*/
|
|
2974
|
-
const mapBoth: <A, C, B, D>(onFirst: (a: A) => C, onSecond: (b: B) => D) => (tuple: Tuple<A, B>) => Tuple<C, D>;
|
|
2975
|
-
/**
|
|
2976
|
-
* Applies a binary function to both values, collapsing the pair into a single value.
|
|
2977
|
-
* Useful as the final step when consuming a pair in a pipeline.
|
|
2978
|
-
*
|
|
2979
|
-
* @example
|
|
2980
|
-
* ```ts
|
|
2981
|
-
* pipe(Tuple.from.pair("Alice", 100), Tuple.fold((name, score) => `${name}: ${score}`));
|
|
2982
|
-
* // "Alice: 100"
|
|
2983
|
-
* ```
|
|
2984
|
-
*/
|
|
2985
|
-
const fold: <A, B, C>(f: (a: A, b: B) => C) => (tuple: Tuple<A, B>) => C;
|
|
2986
|
-
/**
|
|
2987
|
-
* Swaps the two values: `[A, B]` becomes `[B, A]`.
|
|
2988
|
-
*
|
|
2989
|
-
* @example
|
|
2990
|
-
* ```ts
|
|
2991
|
-
* Tuple.swap(Tuple.from.pair("key", 1)); // [1, "key"]
|
|
2992
|
-
* ```
|
|
2993
|
-
*/
|
|
2994
|
-
const swap: <A, B>(tuple: Tuple<A, B>) => Tuple<B, A>;
|
|
2995
|
-
namespace to {
|
|
2996
|
-
/**
|
|
2997
|
-
* Converts the pair to a heterogeneous readonly array `readonly (A | B)[]`.
|
|
2998
|
-
*
|
|
2999
|
-
* @example
|
|
3000
|
-
* ```ts
|
|
3001
|
-
* Tuple.to.Array(Tuple.from.pair("hello", 42)); // ["hello", 42]
|
|
3002
|
-
* ```
|
|
3003
|
-
*/
|
|
3004
|
-
const Array: <A, B>(tuple: Tuple<A, B>) => readonly (A | B)[];
|
|
3005
|
-
}
|
|
3006
|
-
/**
|
|
3007
|
-
* Runs a side effect with both values without changing the pair.
|
|
3008
|
-
* Useful for logging or debugging in the middle of a pipeline.
|
|
3009
|
-
*
|
|
3010
|
-
* @example
|
|
3011
|
-
* ```ts
|
|
3012
|
-
* pipe(
|
|
3013
|
-
* Tuple.from.pair("Paris", 2_161_000),
|
|
3014
|
-
* Tuple.tap((city, pop) => console.log(`${city}: ${pop}`)),
|
|
3015
|
-
* Tuple.mapSecond((n) => n / 1_000_000),
|
|
3016
|
-
* ); // logs "Paris: 2161000", returns ["Paris", 2.161]
|
|
3017
|
-
* ```
|
|
3018
|
-
*/
|
|
3019
|
-
const tap: <A, B>(f: (a: A, b: B) => void) => (tuple: Tuple<A, B>) => Tuple<A, B>;
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
export { Combinable, Deferred, type Failure, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, Stream, type Success, Task, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple };
|
|
3022
|
+
export { Combinable, Deferred, type Failure, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Pair, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, Stream, type Success, Task, These, type TheseBoth, type TheseFirst, type TheseSecond };
|
package/dist/core.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Op,
|
|
10
10
|
Optional,
|
|
11
11
|
Ordering,
|
|
12
|
+
Pair,
|
|
12
13
|
Predicate,
|
|
13
14
|
Reader,
|
|
14
15
|
Refinement,
|
|
@@ -19,9 +20,8 @@ import {
|
|
|
19
20
|
Stream,
|
|
20
21
|
Task,
|
|
21
22
|
These,
|
|
22
|
-
Tuple,
|
|
23
23
|
Validation
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-VYHAA4KO.js";
|
|
25
25
|
import "./chunk-OIIOGDHK.js";
|
|
26
26
|
export {
|
|
27
27
|
Combinable,
|
|
@@ -34,6 +34,7 @@ export {
|
|
|
34
34
|
Op,
|
|
35
35
|
Optional,
|
|
36
36
|
Ordering,
|
|
37
|
+
Pair,
|
|
37
38
|
Predicate,
|
|
38
39
|
Reader,
|
|
39
40
|
Refinement,
|
|
@@ -44,6 +45,5 @@ export {
|
|
|
44
45
|
Stream,
|
|
45
46
|
Task,
|
|
46
47
|
These,
|
|
47
|
-
Tuple,
|
|
48
48
|
Validation
|
|
49
49
|
};
|
package/dist/data.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as NonEmptyArr, N as NonEmpty } from './InternalTypes-DuK_XpTi.cjs';
|
|
2
|
-
import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Validation-
|
|
2
|
+
import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Validation-DC3uUizM.cjs';
|
|
3
3
|
import { B as Brand } from './Duration-B8joKzro.cjs';
|
|
4
4
|
import './types.cjs';
|
|
5
5
|
|
package/dist/data.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as NonEmptyArr, N as NonEmpty } from './InternalTypes-LdhLQx3N.js';
|
|
2
|
-
import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Validation-
|
|
2
|
+
import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Validation-DZLizBZ0.js';
|
|
3
3
|
import { B as Brand } from './Duration-B8joKzro.js';
|
|
4
4
|
import './types.js';
|
|
5
5
|
|
package/dist/data.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
Op: () => Op,
|
|
38
38
|
Optional: () => Optional,
|
|
39
39
|
Ordering: () => Ordering,
|
|
40
|
+
Pair: () => Pair,
|
|
40
41
|
Predicate: () => Predicate,
|
|
41
42
|
Reader: () => Reader,
|
|
42
43
|
Rec: () => Rec,
|
|
@@ -50,7 +51,6 @@ __export(src_exports, {
|
|
|
50
51
|
Stream: () => Stream,
|
|
51
52
|
Task: () => Task,
|
|
52
53
|
These: () => These,
|
|
53
|
-
Tuple: () => Tuple,
|
|
54
54
|
Uniq: () => Uniq,
|
|
55
55
|
Validation: () => Validation,
|
|
56
56
|
and: () => and,
|
|
@@ -1955,6 +1955,34 @@ var Ordering;
|
|
|
1955
1955
|
};
|
|
1956
1956
|
})(Ordering || (Ordering = {}));
|
|
1957
1957
|
|
|
1958
|
+
// src/Core/Pair.ts
|
|
1959
|
+
var Pair;
|
|
1960
|
+
((Pair2) => {
|
|
1961
|
+
let from;
|
|
1962
|
+
((from2) => {
|
|
1963
|
+
from2.pair = (first2, second2) => [first2, second2];
|
|
1964
|
+
from2.array = (arr) => arr;
|
|
1965
|
+
})(from = Pair2.from || (Pair2.from = {}));
|
|
1966
|
+
Pair2.first = (p) => p[0];
|
|
1967
|
+
Pair2.second = (p) => p[1];
|
|
1968
|
+
Pair2.mapFirst = (f) => (p) => [f(p[0]), p[1]];
|
|
1969
|
+
Pair2.mapSecond = (f) => (p) => [p[0], f(p[1])];
|
|
1970
|
+
Pair2.mapBoth = (onFirst, onSecond) => (p) => [
|
|
1971
|
+
onFirst(p[0]),
|
|
1972
|
+
onSecond(p[1])
|
|
1973
|
+
];
|
|
1974
|
+
Pair2.fold = (f) => (p) => f(p[0], p[1]);
|
|
1975
|
+
Pair2.swap = (p) => [p[1], p[0]];
|
|
1976
|
+
let to;
|
|
1977
|
+
((to2) => {
|
|
1978
|
+
to2.Array = (p) => [...p];
|
|
1979
|
+
})(to = Pair2.to || (Pair2.to = {}));
|
|
1980
|
+
Pair2.tap = (f) => (p) => {
|
|
1981
|
+
f(p[0], p[1]);
|
|
1982
|
+
return p;
|
|
1983
|
+
};
|
|
1984
|
+
})(Pair || (Pair = {}));
|
|
1985
|
+
|
|
1958
1986
|
// src/Core/Predicate.ts
|
|
1959
1987
|
var Predicate;
|
|
1960
1988
|
((Predicate2) => {
|
|
@@ -2504,6 +2532,9 @@ var TaskResult;
|
|
|
2504
2532
|
TaskResult2.recover = (fallback) => (data) => Task.chain(
|
|
2505
2533
|
(result) => Result.is.err(result) ? fallback(result.error) : Task.resolve(result)
|
|
2506
2534
|
)(data);
|
|
2535
|
+
TaskResult2.recoverUnless = (isBlocked, fallback) => (data) => Task.chain(
|
|
2536
|
+
(result) => Result.is.err(result) && !isBlocked(result.error) ? fallback(result.error) : Task.resolve(result)
|
|
2537
|
+
)(data);
|
|
2507
2538
|
TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
|
|
2508
2539
|
TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
|
|
2509
2540
|
TaskResult2.tapError = (f) => (data) => Task.map(Result.tapError(f))(data);
|
|
@@ -2614,6 +2645,11 @@ var TaskValidation;
|
|
|
2614
2645
|
);
|
|
2615
2646
|
from2.Result = (result) => Task.resolve(Validation.from.Result(result));
|
|
2616
2647
|
})(from = TaskValidation2.from || (TaskValidation2.from = {}));
|
|
2648
|
+
let to;
|
|
2649
|
+
((to2) => {
|
|
2650
|
+
to2.Result = (combineErrors) => (data) => Task.map(Validation.to.Result(combineErrors))(data);
|
|
2651
|
+
to2.Maybe = (data) => Task.map(Validation.to.Maybe)(data);
|
|
2652
|
+
})(to = TaskValidation2.to || (TaskValidation2.to = {}));
|
|
2617
2653
|
TaskValidation2.tryCatch = (f, options) => (signal) => Deferred.from.Promise(
|
|
2618
2654
|
globalThis.Promise.resolve().then(async () => f(signal)).then(Validation.make.passed).catch(
|
|
2619
2655
|
(error) => Validation.make.failed(options.onError(error))
|
|
@@ -2632,6 +2668,9 @@ var TaskValidation;
|
|
|
2632
2668
|
TaskValidation2.recover = (fallback) => (data) => Task.chain(
|
|
2633
2669
|
(validation) => Validation.is.passed(validation) ? Task.resolve(validation) : fallback(validation.errors)
|
|
2634
2670
|
)(data);
|
|
2671
|
+
TaskValidation2.recoverUnless = (isBlocked, fallback) => (data) => Task.chain(
|
|
2672
|
+
(validation) => Validation.is.passed(validation) ? Task.resolve(validation) : isBlocked(validation.errors) ? Task.resolve(validation) : fallback(validation.errors)
|
|
2673
|
+
)(data);
|
|
2635
2674
|
TaskValidation2.product = (first, second) => (signal) => Deferred.from.Promise(
|
|
2636
2675
|
Promise.all([Deferred.to.Promise(first(signal)), Deferred.to.Promise(second(signal))]).then(
|
|
2637
2676
|
([va, vb]) => Validation.product(va, vb)
|
|
@@ -3002,34 +3041,6 @@ var These;
|
|
|
3002
3041
|
};
|
|
3003
3042
|
})(These || (These = {}));
|
|
3004
3043
|
|
|
3005
|
-
// src/Core/Tuple.ts
|
|
3006
|
-
var Tuple;
|
|
3007
|
-
((Tuple2) => {
|
|
3008
|
-
let from;
|
|
3009
|
-
((from2) => {
|
|
3010
|
-
from2.pair = (first2, second2) => [first2, second2];
|
|
3011
|
-
from2.array = (arr) => arr;
|
|
3012
|
-
})(from = Tuple2.from || (Tuple2.from = {}));
|
|
3013
|
-
Tuple2.first = (tuple2) => tuple2[0];
|
|
3014
|
-
Tuple2.second = (tuple2) => tuple2[1];
|
|
3015
|
-
Tuple2.mapFirst = (f) => (tuple2) => [f(tuple2[0]), tuple2[1]];
|
|
3016
|
-
Tuple2.mapSecond = (f) => (tuple2) => [tuple2[0], f(tuple2[1])];
|
|
3017
|
-
Tuple2.mapBoth = (onFirst, onSecond) => (tuple2) => [
|
|
3018
|
-
onFirst(tuple2[0]),
|
|
3019
|
-
onSecond(tuple2[1])
|
|
3020
|
-
];
|
|
3021
|
-
Tuple2.fold = (f) => (tuple2) => f(tuple2[0], tuple2[1]);
|
|
3022
|
-
Tuple2.swap = (tuple2) => [tuple2[1], tuple2[0]];
|
|
3023
|
-
let to;
|
|
3024
|
-
((to2) => {
|
|
3025
|
-
to2.Array = (tuple2) => [...tuple2];
|
|
3026
|
-
})(to = Tuple2.to || (Tuple2.to = {}));
|
|
3027
|
-
Tuple2.tap = (f) => (tuple2) => {
|
|
3028
|
-
f(tuple2[0], tuple2[1]);
|
|
3029
|
-
return tuple2;
|
|
3030
|
-
};
|
|
3031
|
-
})(Tuple || (Tuple = {}));
|
|
3032
|
-
|
|
3033
3044
|
// src/Core/Validation.ts
|
|
3034
3045
|
var Validation;
|
|
3035
3046
|
((Validation2) => {
|
|
@@ -4461,6 +4472,7 @@ var Uniq;
|
|
|
4461
4472
|
Op,
|
|
4462
4473
|
Optional,
|
|
4463
4474
|
Ordering,
|
|
4475
|
+
Pair,
|
|
4464
4476
|
Predicate,
|
|
4465
4477
|
Reader,
|
|
4466
4478
|
Rec,
|
|
@@ -4474,7 +4486,6 @@ var Uniq;
|
|
|
4474
4486
|
Stream,
|
|
4475
4487
|
Task,
|
|
4476
4488
|
These,
|
|
4477
|
-
Tuple,
|
|
4478
4489
|
Uniq,
|
|
4479
4490
|
Validation,
|
|
4480
4491
|
and,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { and, compose, constFalse, constNull, constTrue, constUndefined, constVoid, constant, converge, curry, curry3, curry4, defaultTo, flip, flow, identity, juxt, memoize, memoizeWeak, not, on, once, or, pipe, tap, tuple, uncurry, uncurry3, uncurry4, untuple } from './composition.cjs';
|
|
2
|
-
export { Combinable, Failure, Lazy, Lens, Loading, Logged, NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, State, Stream, Success, These, TheseBoth, TheseFirst, TheseSecond
|
|
2
|
+
export { Combinable, Failure, Lazy, Lens, Loading, Logged, NotAsked, Op, Optional, Pair, Predicate, Reader, Refinement, RemoteData, Resource, State, Stream, Success, These, TheseBoth, TheseFirst, TheseSecond } from './core.cjs';
|
|
3
3
|
export { D as Deferred } from './InternalTypes-DuK_XpTi.cjs';
|
|
4
|
-
export { E as Equality, a as Err, F as Failed, M as Maybe, N as None, O as Ok, b as Ordering, P as Passed, R as Result, S as Some, T as Task, V as Validation } from './Validation-
|
|
4
|
+
export { E as Equality, a as Err, F as Failed, M as Maybe, N as None, O as Ok, b as Ordering, P as Passed, R as Result, S as Some, T as Task, V as Validation } from './Validation-DC3uUizM.cjs';
|
|
5
5
|
export { Arr, BigNum, Dict, Json, NonEmptyMap, NonEmptyRecord, NonEmptySet, NonEmptyString, Num, Rec, Str, Uniq } from './data.cjs';
|
|
6
6
|
export { B as Brand, D as Duration } from './Duration-B8joKzro.cjs';
|
|
7
7
|
export { RetryPolicy } from './types.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { and, compose, constFalse, constNull, constTrue, constUndefined, constVoid, constant, converge, curry, curry3, curry4, defaultTo, flip, flow, identity, juxt, memoize, memoizeWeak, not, on, once, or, pipe, tap, tuple, uncurry, uncurry3, uncurry4, untuple } from './composition.js';
|
|
2
|
-
export { Combinable, Failure, Lazy, Lens, Loading, Logged, NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, State, Stream, Success, These, TheseBoth, TheseFirst, TheseSecond
|
|
2
|
+
export { Combinable, Failure, Lazy, Lens, Loading, Logged, NotAsked, Op, Optional, Pair, Predicate, Reader, Refinement, RemoteData, Resource, State, Stream, Success, These, TheseBoth, TheseFirst, TheseSecond } from './core.js';
|
|
3
3
|
export { D as Deferred } from './InternalTypes-LdhLQx3N.js';
|
|
4
|
-
export { E as Equality, a as Err, F as Failed, M as Maybe, N as None, O as Ok, b as Ordering, P as Passed, R as Result, S as Some, T as Task, V as Validation } from './Validation-
|
|
4
|
+
export { E as Equality, a as Err, F as Failed, M as Maybe, N as None, O as Ok, b as Ordering, P as Passed, R as Result, S as Some, T as Task, V as Validation } from './Validation-DZLizBZ0.js';
|
|
5
5
|
export { Arr, BigNum, Dict, Json, NonEmptyMap, NonEmptyRecord, NonEmptySet, NonEmptyString, Num, Rec, Str, Uniq } from './data.js';
|
|
6
6
|
export { B as Brand, D as Duration } from './Duration-B8joKzro.js';
|
|
7
7
|
export { RetryPolicy } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
Rec,
|
|
40
40
|
Str,
|
|
41
41
|
Uniq
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-FVWJMPQI.js";
|
|
43
43
|
import {
|
|
44
44
|
Combinable,
|
|
45
45
|
Deferred,
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
Op,
|
|
52
52
|
Optional,
|
|
53
53
|
Ordering,
|
|
54
|
+
Pair,
|
|
54
55
|
Predicate,
|
|
55
56
|
Reader,
|
|
56
57
|
Refinement,
|
|
@@ -61,9 +62,8 @@ import {
|
|
|
61
62
|
Stream,
|
|
62
63
|
Task,
|
|
63
64
|
These,
|
|
64
|
-
Tuple,
|
|
65
65
|
Validation
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-VYHAA4KO.js";
|
|
67
67
|
import {
|
|
68
68
|
Brand,
|
|
69
69
|
Duration,
|
|
@@ -87,6 +87,7 @@ export {
|
|
|
87
87
|
Op,
|
|
88
88
|
Optional,
|
|
89
89
|
Ordering,
|
|
90
|
+
Pair,
|
|
90
91
|
Predicate,
|
|
91
92
|
Reader,
|
|
92
93
|
Rec,
|
|
@@ -100,7 +101,6 @@ export {
|
|
|
100
101
|
Stream,
|
|
101
102
|
Task,
|
|
102
103
|
These,
|
|
103
|
-
Tuple,
|
|
104
104
|
Uniq,
|
|
105
105
|
Validation,
|
|
106
106
|
and,
|