@nlozgachev/pipelined 0.54.0 → 0.55.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.
@@ -1,4 +1,4 @@
1
- import { D as Duration } from './Duration-B8joKzro.mjs';
1
+ import { D as Duration } from './Duration-B8joKzro.cjs';
2
2
 
3
3
  declare const _deferred: unique symbol;
4
4
  /**
@@ -1,6 +1,6 @@
1
- import { h as WithKind, o as WithValue, e as WithError, a as NonEmptyArr, T as Thenable, D as Deferred, f as WithErrors } from './InternalTypes-CDiDBAY4.mjs';
2
- import { D as Duration } from './Duration-B8joKzro.mjs';
3
- import { RetryPolicy } from './types.mjs';
1
+ import { h as WithKind, o as WithValue, e as WithError, a as NonEmptyArr, T as Thenable, D as Deferred, f as WithErrors } from './InternalTypes-DuK_XpTi.cjs';
2
+ import { D as Duration } from './Duration-B8joKzro.cjs';
3
+ import { RetryPolicy } from './types.cjs';
4
4
 
5
5
  /**
6
6
  * A function that checks whether two values of type `A` are equal.
@@ -595,13 +595,16 @@ declare namespace Result {
595
595
  * Creates a Result from a function that may throw.
596
596
  * Catches any errors and transforms them using the onError function.
597
597
  *
598
+ /**
599
+ * Creates a Result from a synchronous thunk that may throw.
600
+ * Catches any errors and transforms them using the `onError` function.
601
+ *
598
602
  * @example
599
603
  * ```ts
600
- * const parseJson = (s: string): Result<string, unknown> =>
601
- * Result.tryCatch(
602
- * () => JSON.parse(s),
603
- * { onError: (e) => `Parse error: ${e}` }
604
- * );
604
+ * const result = Result.tryCatch(
605
+ * () => JSON.parse(rawString),
606
+ * { onError: (e) => `Parse error: ${e}` }
607
+ * );
605
608
  * ```
606
609
  */
607
610
  const tryCatch: <E, A>(f: () => A, options: {
@@ -749,24 +752,6 @@ declare namespace Result {
749
752
  * ```
750
753
  */
751
754
  const Maybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => Result<E, A>;
752
- /**
753
- * Wraps a throwing function of any arguments, returning a new function
754
- * that catches errors and returns a Result.
755
- *
756
- * @example
757
- * ```ts
758
- * const safeParse = Result.from.throwable(
759
- * (s: string) => JSON.parse(s),
760
- * { onError: (e) => new Error(`Parse error: ${e}`) }
761
- * );
762
- *
763
- * safeParse('{"a":1}'); // Ok({ a: 1 })
764
- * safeParse('invalid'); // Err(Error)
765
- * ```
766
- */
767
- const throwable: <Args extends readonly unknown[], A, E>(f: (...args: Args) => A, options: {
768
- onError: (e: unknown) => E;
769
- }) => (...args: Args) => Result<E, A>;
770
755
  /**
771
756
  * Converts a `Validation` to a `Result`, combining accumulated errors using `combineErrors`.
772
757
  * `Passed(a)` becomes `Ok(a)`; `Failed(errors)` becomes `Err(combineErrors(errors))`.
@@ -1159,7 +1144,7 @@ declare namespace TaskResult {
1159
1144
  * const res = await task(); // Ok(42)
1160
1145
  * ```
1161
1146
  */
1162
- const ok: <E, A>(value: A) => TaskResult<E, A>;
1147
+ const ok: <E = never, A = unknown>(value: A) => TaskResult<E, A>;
1163
1148
  /**
1164
1149
  * Creates a failed Task.Result with the given error.
1165
1150
  *
@@ -1169,10 +1154,10 @@ declare namespace TaskResult {
1169
1154
  * const res = await task(); // Err("failed")
1170
1155
  * ```
1171
1156
  */
1172
- const err: <E, A>(error: E) => TaskResult<E, A>;
1157
+ const err: <E, A = never>(error: E) => TaskResult<E, A>;
1173
1158
  }
1174
- const ok: <E, A>(value: A) => TaskResult<E, A>;
1175
- const err: <E, A>(error: E) => TaskResult<E, A>;
1159
+ const ok: <E = never, A = unknown>(value: A) => TaskResult<E, A>;
1160
+ const err: <E, A = never>(error: E) => TaskResult<E, A>;
1176
1161
  namespace from {
1177
1162
  /**
1178
1163
  * Creates a Task.Result from a nullable value.
@@ -1204,14 +1189,15 @@ declare namespace TaskResult {
1204
1189
  * Task.Result.from.Result(Result.make.ok(42)); // resolves to Ok(42)
1205
1190
  * ```
1206
1191
  */
1207
- const Result: <E, A>(result: Result<E, A>) => TaskResult<E, A>;
1208
1192
  /**
1209
- * Wraps a Promise-returning function of any arguments, returning a new function
1210
- * that catches rejections and returns a Task.Result.
1193
+ * Lifts a Result into a Task.Result.
1194
+ *
1195
+ * @example
1196
+ * ```ts
1197
+ * Task.Result.from.Result(Result.make.ok(42)); // resolves to Ok(42)
1198
+ * ```
1211
1199
  */
1212
- const throwable: <Args extends readonly unknown[], A, E>(f: (...args: Args) => Promise<A>, options: {
1213
- onError: (e: unknown) => E;
1214
- }) => (...args: Args) => TaskResult<E, A>;
1200
+ const Result: <E, A>(result: Result<E, A>) => TaskResult<E, A>;
1215
1201
  }
1216
1202
  namespace to {
1217
1203
  /**
@@ -1226,21 +1212,20 @@ declare namespace TaskResult {
1226
1212
  const Maybe: <E, A>(data: TaskResult<E, A>) => TaskMaybe<A>;
1227
1213
  }
1228
1214
  /**
1229
- * Creates a Task.Result from a function that may throw.
1230
- * Catches any errors and transforms them using the onError function.
1231
- * The factory optionally receives an `AbortSignal` forwarded from the call site.
1215
+ * Creates a Task.Result from a Promise-returning thunk that may throw or reject.
1216
+ * Catches any errors and transforms them using the `onError` function into an `Err`.
1217
+ * The thunk optionally receives an `AbortSignal` forwarded from the call site.
1232
1218
  *
1233
1219
  * @example
1234
1220
  * ```ts
1235
- * const fetchUser = (id: string): Task.Result<string, User> =>
1236
- * Task.Result.tryCatch(
1237
- * (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
1238
- * { onError: String }
1239
- * );
1221
+ * const loadUser = Task.Result.tryCatch(
1222
+ * (signal) => userStore.get("u_123", { signal }),
1223
+ * { onError: (e) => new DbError(e) }
1224
+ * );
1240
1225
  * ```
1241
1226
  */
1242
1227
  const tryCatch: <E, A>(f: (signal?: AbortSignal) => Thenable<A>, options: {
1243
- onError: (e: unknown) => E;
1228
+ onError: (error: unknown) => E;
1244
1229
  }) => TaskResult<E, A>;
1245
1230
  /**
1246
1231
  * Transforms the success value inside a Task.Result.
@@ -1436,7 +1421,7 @@ declare namespace TaskValidation {
1436
1421
  * const res = await task(); // Passed(42)
1437
1422
  * ```
1438
1423
  */
1439
- const passed: <E, A>(value: A) => TaskValidation<E, A>;
1424
+ const passed: <E = never, A = unknown>(value: A) => TaskValidation<E, A>;
1440
1425
  /**
1441
1426
  * Creates a failed Task.Validation with a single error.
1442
1427
  *
@@ -1446,7 +1431,7 @@ declare namespace TaskValidation {
1446
1431
  * const res = await task(); // Failed(["invalid"])
1447
1432
  * ```
1448
1433
  */
1449
- const failed: <E, A>(error: E) => TaskValidation<E, A>;
1434
+ const failed: <E, A = never>(error: E) => TaskValidation<E, A>;
1450
1435
  /**
1451
1436
  * Creates a failed Task.Validation from multiple errors.
1452
1437
  *
@@ -1456,11 +1441,11 @@ declare namespace TaskValidation {
1456
1441
  * const res = await task(); // Failed(["err1", "err2"])
1457
1442
  * ```
1458
1443
  */
1459
- const failedAll: <E, A>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1444
+ const failedAll: <E, A = never>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1460
1445
  }
1461
- const passed: <E, A>(value: A) => TaskValidation<E, A>;
1462
- const failed: <E, A>(error: E) => TaskValidation<E, A>;
1463
- const failedAll: <E, A>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1446
+ const passed: <E = never, A = unknown>(value: A) => TaskValidation<E, A>;
1447
+ const failed: <E, A = never>(error: E) => TaskValidation<E, A>;
1448
+ const failedAll: <E, A = never>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1464
1449
  namespace from {
1465
1450
  /**
1466
1451
  * Lifts a Validation into a Task.Validation.
@@ -1510,17 +1495,22 @@ declare namespace TaskValidation {
1510
1495
  * Creates a Task.Validation from a Promise-returning function.
1511
1496
  * Catches any errors and transforms them using the onError function.
1512
1497
  * The factory optionally receives an `AbortSignal` forwarded from the call site.
1498
+ /**
1499
+ * Creates a Task.Validation from a Promise-returning thunk that may throw or reject.
1500
+ * Catches any errors and transforms them using the `onError` function into a Failed validation.
1501
+ * The thunk optionally receives an `AbortSignal` forwarded from the call site.
1513
1502
  *
1514
1503
  * @example
1515
1504
  * ```ts
1516
- * const fetchUser = (id: string): Task.Validation<string, User> =>
1517
- * Task.Validation.tryCatch(
1518
- * (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
1519
- * e => `Failed to fetch user: ${e}`
1520
- * );
1505
+ * const loadConfig = Task.Validation.tryCatch(
1506
+ * (signal) => configStore.get("default", { signal }),
1507
+ * { onError: (e) => `Failed to load config: ${e}` }
1508
+ * );
1521
1509
  * ```
1522
1510
  */
1523
- const tryCatch: <E, A>(f: (signal?: AbortSignal) => Thenable<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
1511
+ const tryCatch: <E, A>(f: (signal?: AbortSignal) => Thenable<A>, options: {
1512
+ onError: (error: unknown) => E;
1513
+ }) => TaskValidation<E, A>;
1524
1514
  /**
1525
1515
  * Transforms the success value inside a Task.Validation.
1526
1516
  */
@@ -1701,16 +1691,6 @@ declare namespace Task {
1701
1691
  */
1702
1692
  const resolve: <A>(value: A) => Task<A>;
1703
1693
  namespace from {
1704
- /**
1705
- * Creates a Task from a function that returns a Promise.
1706
- * The factory optionally receives an `AbortSignal` forwarded from the call site.
1707
- *
1708
- * @example
1709
- * ```ts
1710
- * const getTimestamp = Task.from.Promise(() => Promise.resolve(Date.now()));
1711
- * ```
1712
- */
1713
- const Promise: <A>(f: (signal?: AbortSignal) => Thenable<A>) => Task<A>;
1714
1694
  /**
1715
1695
  * Creates a Task from a lazy synchronous thunk.
1716
1696
  * Unlike `Task.resolve(f())`, `from.sync` does not evaluate `f` until the Task is called.
@@ -1723,6 +1703,21 @@ declare namespace Task {
1723
1703
  */
1724
1704
  const sync: <A>(f: () => A) => Task<A>;
1725
1705
  }
1706
+ /**
1707
+ * Wraps a Promise-returning thunk that may throw or reject,
1708
+ * trapping errors with a fallback function and returning a guaranteed `Task<A>`.
1709
+ *
1710
+ * @example
1711
+ * ```ts
1712
+ * const loadConfig = Task.tryCatch(
1713
+ * () => configStore.get("default"),
1714
+ * { onError: () => DEFAULT_CONFIG }
1715
+ * );
1716
+ * ```
1717
+ */
1718
+ const tryCatch: <A>(f: (signal?: AbortSignal) => globalThis.Promise<A>, options: {
1719
+ onError: (error: unknown) => A;
1720
+ }) => Task<A>;
1726
1721
  /**
1727
1722
  * Transforms the value inside a Task.
1728
1723
  *
@@ -1845,8 +1840,8 @@ declare namespace Task {
1845
1840
  *
1846
1841
  * @example
1847
1842
  * ```ts
1848
- * const fast = Task.from.Promise(() => new Promise<string>(r => setTimeout(() => r("fast"), 10)));
1849
- * const slow = Task.from.Promise(() => new Promise<string>(r => setTimeout(() => r("slow"), 200)));
1843
+ * const fast = Task.resolve("fast");
1844
+ * const slow = Task.delay(Duration.milliseconds(200))(Task.resolve("slow"));
1850
1845
  *
1851
1846
  * await Task.race([fast, slow])(); // "fast"
1852
1847
  * ```
@@ -1870,10 +1865,7 @@ declare namespace Task {
1870
1865
  * @example
1871
1866
  * ```ts
1872
1867
  * let log: number[] = [];
1873
- * const makeTask = (n: number) => Task.from.Promise(() => {
1874
- * log.push(n);
1875
- * return Promise.resolve(n);
1876
- * });
1868
+ * const makeTask = (n: number) => Task.resolve(n);
1877
1869
  *
1878
1870
  * await Task.sequential([makeTask(1), makeTask(2), makeTask(3)])();
1879
1871
  * // log = [1, 2, 3] — tasks ran in order
@@ -2089,16 +2081,15 @@ declare namespace Validation {
2089
2081
  const failed: <E, A>(data: Validation<E, A>) => data is Failed<E>;
2090
2082
  }
2091
2083
  /**
2092
- * Creates a Validation from a function that may throw.
2093
- * Catches any errors and transforms them using the onError function into a Failed validation.
2084
+ * Creates a Validation from a synchronous thunk that may throw.
2085
+ * Catches any errors and transforms them using the `onError` function into a Failed validation.
2094
2086
  *
2095
2087
  * @example
2096
2088
  * ```ts
2097
- * const parseJson = (s: string): Validation<string, unknown> =>
2098
- * Validation.tryCatch(
2099
- * () => JSON.parse(s),
2100
- * { onError: (e) => `Parse error: ${e}` }
2101
- * );
2089
+ * const result = Validation.tryCatch(
2090
+ * () => JSON.parse(rawString),
2091
+ * { onError: (e) => `Parse error: ${e}` }
2092
+ * );
2102
2093
  * ```
2103
2094
  */
2104
2095
  const tryCatch: <E, A>(f: () => A, options: {
@@ -595,13 +595,16 @@ declare namespace Result {
595
595
  * Creates a Result from a function that may throw.
596
596
  * Catches any errors and transforms them using the onError function.
597
597
  *
598
+ /**
599
+ * Creates a Result from a synchronous thunk that may throw.
600
+ * Catches any errors and transforms them using the `onError` function.
601
+ *
598
602
  * @example
599
603
  * ```ts
600
- * const parseJson = (s: string): Result<string, unknown> =>
601
- * Result.tryCatch(
602
- * () => JSON.parse(s),
603
- * { onError: (e) => `Parse error: ${e}` }
604
- * );
604
+ * const result = Result.tryCatch(
605
+ * () => JSON.parse(rawString),
606
+ * { onError: (e) => `Parse error: ${e}` }
607
+ * );
605
608
  * ```
606
609
  */
607
610
  const tryCatch: <E, A>(f: () => A, options: {
@@ -749,24 +752,6 @@ declare namespace Result {
749
752
  * ```
750
753
  */
751
754
  const Maybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => Result<E, A>;
752
- /**
753
- * Wraps a throwing function of any arguments, returning a new function
754
- * that catches errors and returns a Result.
755
- *
756
- * @example
757
- * ```ts
758
- * const safeParse = Result.from.throwable(
759
- * (s: string) => JSON.parse(s),
760
- * { onError: (e) => new Error(`Parse error: ${e}`) }
761
- * );
762
- *
763
- * safeParse('{"a":1}'); // Ok({ a: 1 })
764
- * safeParse('invalid'); // Err(Error)
765
- * ```
766
- */
767
- const throwable: <Args extends readonly unknown[], A, E>(f: (...args: Args) => A, options: {
768
- onError: (e: unknown) => E;
769
- }) => (...args: Args) => Result<E, A>;
770
755
  /**
771
756
  * Converts a `Validation` to a `Result`, combining accumulated errors using `combineErrors`.
772
757
  * `Passed(a)` becomes `Ok(a)`; `Failed(errors)` becomes `Err(combineErrors(errors))`.
@@ -1159,7 +1144,7 @@ declare namespace TaskResult {
1159
1144
  * const res = await task(); // Ok(42)
1160
1145
  * ```
1161
1146
  */
1162
- const ok: <E, A>(value: A) => TaskResult<E, A>;
1147
+ const ok: <E = never, A = unknown>(value: A) => TaskResult<E, A>;
1163
1148
  /**
1164
1149
  * Creates a failed Task.Result with the given error.
1165
1150
  *
@@ -1169,10 +1154,10 @@ declare namespace TaskResult {
1169
1154
  * const res = await task(); // Err("failed")
1170
1155
  * ```
1171
1156
  */
1172
- const err: <E, A>(error: E) => TaskResult<E, A>;
1157
+ const err: <E, A = never>(error: E) => TaskResult<E, A>;
1173
1158
  }
1174
- const ok: <E, A>(value: A) => TaskResult<E, A>;
1175
- const err: <E, A>(error: E) => TaskResult<E, A>;
1159
+ const ok: <E = never, A = unknown>(value: A) => TaskResult<E, A>;
1160
+ const err: <E, A = never>(error: E) => TaskResult<E, A>;
1176
1161
  namespace from {
1177
1162
  /**
1178
1163
  * Creates a Task.Result from a nullable value.
@@ -1204,14 +1189,15 @@ declare namespace TaskResult {
1204
1189
  * Task.Result.from.Result(Result.make.ok(42)); // resolves to Ok(42)
1205
1190
  * ```
1206
1191
  */
1207
- const Result: <E, A>(result: Result<E, A>) => TaskResult<E, A>;
1208
1192
  /**
1209
- * Wraps a Promise-returning function of any arguments, returning a new function
1210
- * that catches rejections and returns a Task.Result.
1193
+ * Lifts a Result into a Task.Result.
1194
+ *
1195
+ * @example
1196
+ * ```ts
1197
+ * Task.Result.from.Result(Result.make.ok(42)); // resolves to Ok(42)
1198
+ * ```
1211
1199
  */
1212
- const throwable: <Args extends readonly unknown[], A, E>(f: (...args: Args) => Promise<A>, options: {
1213
- onError: (e: unknown) => E;
1214
- }) => (...args: Args) => TaskResult<E, A>;
1200
+ const Result: <E, A>(result: Result<E, A>) => TaskResult<E, A>;
1215
1201
  }
1216
1202
  namespace to {
1217
1203
  /**
@@ -1226,21 +1212,20 @@ declare namespace TaskResult {
1226
1212
  const Maybe: <E, A>(data: TaskResult<E, A>) => TaskMaybe<A>;
1227
1213
  }
1228
1214
  /**
1229
- * Creates a Task.Result from a function that may throw.
1230
- * Catches any errors and transforms them using the onError function.
1231
- * The factory optionally receives an `AbortSignal` forwarded from the call site.
1215
+ * Creates a Task.Result from a Promise-returning thunk that may throw or reject.
1216
+ * Catches any errors and transforms them using the `onError` function into an `Err`.
1217
+ * The thunk optionally receives an `AbortSignal` forwarded from the call site.
1232
1218
  *
1233
1219
  * @example
1234
1220
  * ```ts
1235
- * const fetchUser = (id: string): Task.Result<string, User> =>
1236
- * Task.Result.tryCatch(
1237
- * (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
1238
- * { onError: String }
1239
- * );
1221
+ * const loadUser = Task.Result.tryCatch(
1222
+ * (signal) => userStore.get("u_123", { signal }),
1223
+ * { onError: (e) => new DbError(e) }
1224
+ * );
1240
1225
  * ```
1241
1226
  */
1242
1227
  const tryCatch: <E, A>(f: (signal?: AbortSignal) => Thenable<A>, options: {
1243
- onError: (e: unknown) => E;
1228
+ onError: (error: unknown) => E;
1244
1229
  }) => TaskResult<E, A>;
1245
1230
  /**
1246
1231
  * Transforms the success value inside a Task.Result.
@@ -1436,7 +1421,7 @@ declare namespace TaskValidation {
1436
1421
  * const res = await task(); // Passed(42)
1437
1422
  * ```
1438
1423
  */
1439
- const passed: <E, A>(value: A) => TaskValidation<E, A>;
1424
+ const passed: <E = never, A = unknown>(value: A) => TaskValidation<E, A>;
1440
1425
  /**
1441
1426
  * Creates a failed Task.Validation with a single error.
1442
1427
  *
@@ -1446,7 +1431,7 @@ declare namespace TaskValidation {
1446
1431
  * const res = await task(); // Failed(["invalid"])
1447
1432
  * ```
1448
1433
  */
1449
- const failed: <E, A>(error: E) => TaskValidation<E, A>;
1434
+ const failed: <E, A = never>(error: E) => TaskValidation<E, A>;
1450
1435
  /**
1451
1436
  * Creates a failed Task.Validation from multiple errors.
1452
1437
  *
@@ -1456,11 +1441,11 @@ declare namespace TaskValidation {
1456
1441
  * const res = await task(); // Failed(["err1", "err2"])
1457
1442
  * ```
1458
1443
  */
1459
- const failedAll: <E, A>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1444
+ const failedAll: <E, A = never>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1460
1445
  }
1461
- const passed: <E, A>(value: A) => TaskValidation<E, A>;
1462
- const failed: <E, A>(error: E) => TaskValidation<E, A>;
1463
- const failedAll: <E, A>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1446
+ const passed: <E = never, A = unknown>(value: A) => TaskValidation<E, A>;
1447
+ const failed: <E, A = never>(error: E) => TaskValidation<E, A>;
1448
+ const failedAll: <E, A = never>(errors: NonEmptyArr<E>) => TaskValidation<E, A>;
1464
1449
  namespace from {
1465
1450
  /**
1466
1451
  * Lifts a Validation into a Task.Validation.
@@ -1510,17 +1495,22 @@ declare namespace TaskValidation {
1510
1495
  * Creates a Task.Validation from a Promise-returning function.
1511
1496
  * Catches any errors and transforms them using the onError function.
1512
1497
  * The factory optionally receives an `AbortSignal` forwarded from the call site.
1498
+ /**
1499
+ * Creates a Task.Validation from a Promise-returning thunk that may throw or reject.
1500
+ * Catches any errors and transforms them using the `onError` function into a Failed validation.
1501
+ * The thunk optionally receives an `AbortSignal` forwarded from the call site.
1513
1502
  *
1514
1503
  * @example
1515
1504
  * ```ts
1516
- * const fetchUser = (id: string): Task.Validation<string, User> =>
1517
- * Task.Validation.tryCatch(
1518
- * (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
1519
- * e => `Failed to fetch user: ${e}`
1520
- * );
1505
+ * const loadConfig = Task.Validation.tryCatch(
1506
+ * (signal) => configStore.get("default", { signal }),
1507
+ * { onError: (e) => `Failed to load config: ${e}` }
1508
+ * );
1521
1509
  * ```
1522
1510
  */
1523
- const tryCatch: <E, A>(f: (signal?: AbortSignal) => Thenable<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
1511
+ const tryCatch: <E, A>(f: (signal?: AbortSignal) => Thenable<A>, options: {
1512
+ onError: (error: unknown) => E;
1513
+ }) => TaskValidation<E, A>;
1524
1514
  /**
1525
1515
  * Transforms the success value inside a Task.Validation.
1526
1516
  */
@@ -1701,16 +1691,6 @@ declare namespace Task {
1701
1691
  */
1702
1692
  const resolve: <A>(value: A) => Task<A>;
1703
1693
  namespace from {
1704
- /**
1705
- * Creates a Task from a function that returns a Promise.
1706
- * The factory optionally receives an `AbortSignal` forwarded from the call site.
1707
- *
1708
- * @example
1709
- * ```ts
1710
- * const getTimestamp = Task.from.Promise(() => Promise.resolve(Date.now()));
1711
- * ```
1712
- */
1713
- const Promise: <A>(f: (signal?: AbortSignal) => Thenable<A>) => Task<A>;
1714
1694
  /**
1715
1695
  * Creates a Task from a lazy synchronous thunk.
1716
1696
  * Unlike `Task.resolve(f())`, `from.sync` does not evaluate `f` until the Task is called.
@@ -1723,6 +1703,21 @@ declare namespace Task {
1723
1703
  */
1724
1704
  const sync: <A>(f: () => A) => Task<A>;
1725
1705
  }
1706
+ /**
1707
+ * Wraps a Promise-returning thunk that may throw or reject,
1708
+ * trapping errors with a fallback function and returning a guaranteed `Task<A>`.
1709
+ *
1710
+ * @example
1711
+ * ```ts
1712
+ * const loadConfig = Task.tryCatch(
1713
+ * () => configStore.get("default"),
1714
+ * { onError: () => DEFAULT_CONFIG }
1715
+ * );
1716
+ * ```
1717
+ */
1718
+ const tryCatch: <A>(f: (signal?: AbortSignal) => globalThis.Promise<A>, options: {
1719
+ onError: (error: unknown) => A;
1720
+ }) => Task<A>;
1726
1721
  /**
1727
1722
  * Transforms the value inside a Task.
1728
1723
  *
@@ -1845,8 +1840,8 @@ declare namespace Task {
1845
1840
  *
1846
1841
  * @example
1847
1842
  * ```ts
1848
- * const fast = Task.from.Promise(() => new Promise<string>(r => setTimeout(() => r("fast"), 10)));
1849
- * const slow = Task.from.Promise(() => new Promise<string>(r => setTimeout(() => r("slow"), 200)));
1843
+ * const fast = Task.resolve("fast");
1844
+ * const slow = Task.delay(Duration.milliseconds(200))(Task.resolve("slow"));
1850
1845
  *
1851
1846
  * await Task.race([fast, slow])(); // "fast"
1852
1847
  * ```
@@ -1870,10 +1865,7 @@ declare namespace Task {
1870
1865
  * @example
1871
1866
  * ```ts
1872
1867
  * let log: number[] = [];
1873
- * const makeTask = (n: number) => Task.from.Promise(() => {
1874
- * log.push(n);
1875
- * return Promise.resolve(n);
1876
- * });
1868
+ * const makeTask = (n: number) => Task.resolve(n);
1877
1869
  *
1878
1870
  * await Task.sequential([makeTask(1), makeTask(2), makeTask(3)])();
1879
1871
  * // log = [1, 2, 3] — tasks ran in order
@@ -2089,16 +2081,15 @@ declare namespace Validation {
2089
2081
  const failed: <E, A>(data: Validation<E, A>) => data is Failed<E>;
2090
2082
  }
2091
2083
  /**
2092
- * Creates a Validation from a function that may throw.
2093
- * Catches any errors and transforms them using the onError function into a Failed validation.
2084
+ * Creates a Validation from a synchronous thunk that may throw.
2085
+ * Catches any errors and transforms them using the `onError` function into a Failed validation.
2094
2086
  *
2095
2087
  * @example
2096
2088
  * ```ts
2097
- * const parseJson = (s: string): Validation<string, unknown> =>
2098
- * Validation.tryCatch(
2099
- * () => JSON.parse(s),
2100
- * { onError: (e) => `Parse error: ${e}` }
2101
- * );
2089
+ * const result = Validation.tryCatch(
2090
+ * () => JSON.parse(rawString),
2091
+ * { onError: (e) => `Parse error: ${e}` }
2092
+ * );
2102
2093
  * ```
2103
2094
  */
2104
2095
  const tryCatch: <E, A>(f: () => A, options: {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Duration
3
- } from "./chunk-DENXUTKL.mjs";
3
+ } from "./chunk-OIIOGDHK.js";
4
4
 
5
5
  // src/Composition/compose.ts
6
6
  function compose(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9) {