@nlozgachev/pipelined 0.31.0 → 0.32.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/{Task-BDcKwFAj.d.mts → Task-CJZfcOkO.d.mts} +218 -53
- package/dist/{Task-CnF22Q2o.d.ts → Task-CjYKLeTY.d.ts} +218 -53
- package/dist/{chunk-FWYOEWJ2.mjs → chunk-EHQFUWZW.mjs} +57 -4
- package/dist/{chunk-VIC54JR4.mjs → chunk-L3NC44SN.mjs} +122 -21
- package/dist/{chunk-SDGDJ7CU.mjs → chunk-TK5ZCGP2.mjs} +111 -34
- package/dist/core.d.mts +179 -8
- package/dist/core.d.ts +179 -8
- package/dist/core.js +284 -102
- package/dist/core.mjs +10 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +340 -105
- package/dist/index.mjs +11 -3
- package/dist/utils.d.mts +81 -1
- package/dist/utils.d.ts +81 -1
- package/dist/utils.js +156 -26
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,171 @@
|
|
|
1
|
-
import { M as Maybe, W as WithValue,
|
|
2
|
-
export { E as Error, N as None, O as Ok, S as Some } from './Task-
|
|
1
|
+
import { M as Maybe, W as WithValue, c as WithLog, D as Deferred, R as Result, d as WithKind, e as WithError, f as RetryOptions, g as TimeoutOptions, h as WithTimeout, i as WithMinInterval, j as WithCooldown, k as WithConcurrency, l as WithSize, m as WithMs, n as WithN, T as Task, o as WithErrors, p as WithFirst, q as WithSecond } from './Task-CjYKLeTY.js';
|
|
2
|
+
export { E as Equality, a as Error, N as None, O as Ok, b as Ordering, S as Some } from './Task-CjYKLeTY.js';
|
|
3
3
|
import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A type that can combine two values of type `A` into one, with a neutral starting value.
|
|
7
|
+
* `empty` is the identity: `combine(empty)(a) === a` and `combine(a)(empty) === a`.
|
|
8
|
+
* `combine(b)(a)` appends `b` onto `a` — `a` is the accumulated value, `b` is the new element.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* pipe(["hello", ", ", "world"], Combinable.fold(Combinable.string)); // "hello, world"
|
|
13
|
+
* pipe([1, 2, 3, 4, 5], Combinable.fold(Combinable.sum)); // 15
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
type Combinable<A> = {
|
|
17
|
+
readonly empty: A;
|
|
18
|
+
readonly combine: (b: A) => (a: A) => A;
|
|
19
|
+
};
|
|
20
|
+
declare namespace Combinable {
|
|
21
|
+
/**
|
|
22
|
+
* Combines strings by concatenation. Empty string is the neutral element.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* pipe(["a", "b", "c"], Combinable.fold(Combinable.string)); // "abc"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const string: Combinable<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Combines numbers by addition. `0` is the neutral element.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* pipe([1, 2, 3], Combinable.fold(Combinable.sum)); // 6
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
const sum: Combinable<number>;
|
|
39
|
+
/**
|
|
40
|
+
* Combines numbers by multiplication. `1` is the neutral element.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* pipe([2, 3, 4], Combinable.fold(Combinable.product)); // 24
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
const product: Combinable<number>;
|
|
48
|
+
/**
|
|
49
|
+
* Combines booleans with logical AND. `true` is the neutral element.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* pipe([true, true, false], Combinable.fold(Combinable.all)); // false
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
const all: Combinable<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Combines booleans with logical OR. `false` is the neutral element.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* pipe([false, false, true], Combinable.fold(Combinable.any)); // true
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
const any: Combinable<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Combines arrays by concatenation. Empty array is the neutral element.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* pipe([[1, 2], [3], [4, 5]], Combinable.fold(Combinable.array<number>())); // [1, 2, 3, 4, 5]
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
const array: <A>() => Combinable<readonly A[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Lifts a `Combinable<A>` to `Combinable<Maybe<A>>`. `None` is the neutral element —
|
|
77
|
+
* combining with `None` on either side returns the other value unchanged.
|
|
78
|
+
* Two `Some` values combine their inner values using the inner `Combinable`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const c = Combinable.maybe(Combinable.sum);
|
|
83
|
+
* c.combine(Maybe.some(3))(Maybe.some(2)); // Some(5)
|
|
84
|
+
* c.combine(Maybe.none())(Maybe.some(5)); // Some(5)
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
const maybe: <A>(inner: Combinable<A>) => Combinable<Maybe<A>>;
|
|
88
|
+
/**
|
|
89
|
+
* Folds an array into a single value using the `Combinable`'s `empty` as the starting point.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* pipe([1, 2, 3, 4, 5], Combinable.fold(Combinable.sum)); // 15
|
|
94
|
+
* pipe([], Combinable.fold(Combinable.sum)); // 0
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
const fold: <A>(c: Combinable<A>) => (data: readonly A[]) => A;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A synchronous memoized computation. The factory function runs exactly once —
|
|
102
|
+
* on the first call to `Lazy.evaluate` — and the result is cached for all subsequent calls.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* const config = Lazy.from(() => parseConfig(rawInput));
|
|
107
|
+
*
|
|
108
|
+
* pipe(
|
|
109
|
+
* config,
|
|
110
|
+
* Lazy.map(cfg => cfg.port),
|
|
111
|
+
* Lazy.evaluate,
|
|
112
|
+
* ); // parseConfig ran once; cfg.port returned
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
type Lazy<A> = {
|
|
116
|
+
readonly get: () => A;
|
|
117
|
+
};
|
|
118
|
+
declare namespace Lazy {
|
|
119
|
+
/**
|
|
120
|
+
* Wraps a thunk in a `Lazy`. The thunk runs exactly once, on first `evaluate`.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const expensive = Lazy.from(() => computeExpensiveValue(input));
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
const from: <A>(f: () => A) => Lazy<A>;
|
|
128
|
+
/**
|
|
129
|
+
* Forces evaluation and returns the cached result. Safe to call multiple times.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const value = Lazy.evaluate(Lazy.from(() => 42)); // 42
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
const evaluate: <A>(lazy: Lazy<A>) => A;
|
|
137
|
+
/**
|
|
138
|
+
* Transforms the result of a `Lazy` without triggering evaluation.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* pipe(Lazy.from(() => loadConfig()), Lazy.map(cfg => cfg.port));
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
const map: <A, B>(f: (a: A) => B) => (lazy: Lazy<A>) => Lazy<B>;
|
|
146
|
+
/**
|
|
147
|
+
* Chains a `Lazy`-returning transformation without triggering evaluation.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* pipe(
|
|
152
|
+
* Lazy.from(() => loadConfig()),
|
|
153
|
+
* Lazy.chain(cfg => Lazy.from(() => openConnection(cfg.dbUrl))),
|
|
154
|
+
* );
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
const chain: <A, B>(f: (a: A) => Lazy<B>) => (lazy: Lazy<A>) => Lazy<B>;
|
|
158
|
+
/**
|
|
159
|
+
* Runs a side effect on the value without changing it. Fires once, on first `evaluate`.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* pipe(Lazy.from(() => compute()), Lazy.tap(v => console.log("computed:", v)));
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
const tap: <A>(f: (a: A) => void) => (lazy: Lazy<A>) => Lazy<A>;
|
|
167
|
+
}
|
|
168
|
+
|
|
5
169
|
/** Keys of T for which undefined is assignable (i.e. optional fields). */
|
|
6
170
|
type OptionalKeys<T> = {
|
|
7
171
|
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
@@ -1888,6 +2052,11 @@ declare namespace TaskResult {
|
|
|
1888
2052
|
* ```
|
|
1889
2053
|
*/
|
|
1890
2054
|
const tapError: <E, A>(f: (e: E) => void) => (data: TaskResult<E, A>) => TaskResult<E, A>;
|
|
2055
|
+
/**
|
|
2056
|
+
* Applies a function wrapped in a TaskResult to a value wrapped in a TaskResult.
|
|
2057
|
+
* Both Tasks run in parallel.
|
|
2058
|
+
*/
|
|
2059
|
+
const ap: <E, A>(arg: TaskResult<E, A>) => <B>(data: TaskResult<E, (a: A) => B>) => TaskResult<E, B>;
|
|
1891
2060
|
/**
|
|
1892
2061
|
* Executes a `TaskResult` with an optional signal, returning `Promise<Result<E, A>>`.
|
|
1893
2062
|
* Use as a terminal step in a `pipe` chain.
|
|
@@ -2230,15 +2399,16 @@ declare namespace TaskMaybe {
|
|
|
2230
2399
|
/**
|
|
2231
2400
|
* Creates a TaskMaybe from a Promise-returning function.
|
|
2232
2401
|
* Returns Some if the promise resolves, None if it rejects.
|
|
2402
|
+
* The factory optionally receives an `AbortSignal` forwarded from the call site.
|
|
2233
2403
|
*
|
|
2234
2404
|
* @example
|
|
2235
2405
|
* ```ts
|
|
2236
|
-
* const fetchUser = TaskMaybe.tryCatch(() =>
|
|
2237
|
-
* fetch("/user/1").then(r => r.json())
|
|
2406
|
+
* const fetchUser = TaskMaybe.tryCatch((signal) =>
|
|
2407
|
+
* fetch("/user/1", { signal }).then(r => r.json())
|
|
2238
2408
|
* );
|
|
2239
2409
|
* ```
|
|
2240
2410
|
*/
|
|
2241
|
-
const tryCatch: <A>(f: () => Promise<A>) => TaskMaybe<A>;
|
|
2411
|
+
const tryCatch: <A>(f: (signal?: AbortSignal) => Promise<A>) => TaskMaybe<A>;
|
|
2242
2412
|
/**
|
|
2243
2413
|
* Transforms the value inside a TaskMaybe.
|
|
2244
2414
|
*/
|
|
@@ -2627,17 +2797,18 @@ declare namespace TaskValidation {
|
|
|
2627
2797
|
/**
|
|
2628
2798
|
* Creates a TaskValidation from a Promise-returning function.
|
|
2629
2799
|
* Catches any errors and transforms them using the onError function.
|
|
2800
|
+
* The factory optionally receives an `AbortSignal` forwarded from the call site.
|
|
2630
2801
|
*
|
|
2631
2802
|
* @example
|
|
2632
2803
|
* ```ts
|
|
2633
2804
|
* const fetchUser = (id: string): TaskValidation<string, User> =>
|
|
2634
2805
|
* TaskValidation.tryCatch(
|
|
2635
|
-
* () => fetch(`/users/${id}
|
|
2806
|
+
* (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
|
|
2636
2807
|
* e => `Failed to fetch user: ${e}`
|
|
2637
2808
|
* );
|
|
2638
2809
|
* ```
|
|
2639
2810
|
*/
|
|
2640
|
-
const tryCatch: <E, A>(f: () => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
|
|
2811
|
+
const tryCatch: <E, A>(f: (signal?: AbortSignal) => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
|
|
2641
2812
|
/**
|
|
2642
2813
|
* Transforms the success value inside a TaskValidation.
|
|
2643
2814
|
*/
|
|
@@ -3079,4 +3250,4 @@ declare namespace Tuple {
|
|
|
3079
3250
|
const tap: <A, B>(f: (a: A, b: B) => void) => (tuple: Tuple<A, B>) => Tuple<A, B>;
|
|
3080
3251
|
}
|
|
3081
3252
|
|
|
3082
|
-
export { Deferred, type Failure, type Invalid, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, type Success, Task, TaskMaybe, TaskResult, TaskValidation, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple, type Valid, Validation };
|
|
3253
|
+
export { Combinable, Deferred, type Failure, type Invalid, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, type Success, Task, TaskMaybe, TaskResult, TaskValidation, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple, type Valid, Validation };
|