@nlozgachev/pipelined 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/{Duration-B8joKzro.d.cts → Duration-DeyxG6VQ.d.cts} +20 -20
- package/dist/{Duration-B8joKzro.d.ts → Duration-DeyxG6VQ.d.ts} +20 -20
- package/dist/{InternalTypes-LdhLQx3N.d.ts → InternalTypes-CCXa8Kvr.d.ts} +11 -11
- package/dist/{InternalTypes-DuK_XpTi.d.cts → InternalTypes-GFn4RTwD.d.cts} +11 -11
- package/dist/{Validation-DZLizBZ0.d.ts → Validation-C5RGZUXy.d.ts} +384 -280
- package/dist/{Validation-DC3uUizM.d.cts → Validation-KFUpea_k.d.cts} +384 -280
- package/dist/composition.cjs +216 -95
- package/dist/composition.d.cts +8 -76
- package/dist/composition.d.ts +8 -76
- package/dist/composition.mjs +216 -95
- package/dist/core.cjs +4784 -996
- package/dist/core.d.cts +269 -769
- package/dist/core.d.ts +269 -769
- package/dist/core.mjs +4784 -996
- package/dist/data.cjs +2916 -1240
- package/dist/data.d.cts +479 -1967
- package/dist/data.d.ts +479 -1967
- package/dist/data.mjs +2916 -1240
- package/dist/index.cjs +6739 -2169
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +6718 -2148
- package/dist/types.cjs +175 -31
- package/dist/types.d.cts +6 -6
- package/dist/types.d.ts +6 -6
- package/dist/types.mjs +175 -31
- package/package.json +24 -13
package/dist/types.cjs
CHANGED
|
@@ -27,41 +27,185 @@ __export(Types_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(Types_exports);
|
|
28
28
|
|
|
29
29
|
// src/Types/Brand.ts
|
|
30
|
-
var Brand
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
var Brand = {
|
|
31
|
+
/**
|
|
32
|
+
* Returns a constructor that wraps a value of type T in brand K.
|
|
33
|
+
* The resulting function performs an unchecked cast — only use when the raw
|
|
34
|
+
* value is known to satisfy the brand's invariants.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* type PositiveNumber = Brand<"PositiveNumber", number>;
|
|
39
|
+
* const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
|
|
40
|
+
*
|
|
41
|
+
* const n: PositiveNumber = toPositiveNumber(42);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
wrap: () => (value) => value,
|
|
45
|
+
/**
|
|
46
|
+
* Strips the brand and returns the underlying value.
|
|
47
|
+
* Since Brand<K, T> extends T this is rarely needed, but can improve readability.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* type UserId = Brand<"UserId", string>;
|
|
52
|
+
* const toUserId = Brand.wrap<"UserId", string>();
|
|
53
|
+
* const userId: UserId = toUserId("user-123");
|
|
54
|
+
* const raw: string = Brand.unwrap(userId); // "user-123"
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
unwrap: (branded) => branded
|
|
58
|
+
};
|
|
35
59
|
|
|
36
60
|
// src/Types/Duration.ts
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
var wrap = Brand.wrap();
|
|
62
|
+
var Duration = {
|
|
63
|
+
/**
|
|
64
|
+
* Creates a Duration from milliseconds.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* Duration.milliseconds(500); // 500ms Duration
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
milliseconds: (ms) => wrap(ms),
|
|
72
|
+
/**
|
|
73
|
+
* Creates a Duration from seconds.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* Duration.seconds(2); // 2000ms Duration
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
seconds: (s) => wrap(s * 1e3),
|
|
81
|
+
/**
|
|
82
|
+
* Creates a Duration from minutes.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* Duration.minutes(5); // 300000ms Duration
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
minutes: (m) => wrap(m * 60 * 1e3),
|
|
90
|
+
/**
|
|
91
|
+
* Creates a Duration from hours.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* Duration.hours(1); // 3600000ms Duration
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
hours: (h) => wrap(h * 60 * 60 * 1e3),
|
|
99
|
+
/**
|
|
100
|
+
* Creates a Duration from days.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* Duration.days(1); // 86400000ms Duration
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
days: (d) => wrap(d * 24 * 60 * 60 * 1e3),
|
|
108
|
+
// --- to ---
|
|
109
|
+
to: {
|
|
110
|
+
/**
|
|
111
|
+
* Converts a Duration back to raw milliseconds.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* Duration.to.milliseconds(Duration.seconds(2)); // 2000
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
milliseconds: (d) => Brand.unwrap(d),
|
|
119
|
+
/**
|
|
120
|
+
* Converts a Duration to seconds.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* Duration.to.seconds(Duration.milliseconds(2500)); // 2.5
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
seconds: (d) => Brand.unwrap(d) / 1e3,
|
|
128
|
+
/**
|
|
129
|
+
* Converts a Duration to minutes.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* Duration.to.minutes(Duration.seconds(120)); // 2
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
minutes: (d) => Brand.unwrap(d) / (60 * 1e3),
|
|
137
|
+
/**
|
|
138
|
+
* Converts a Duration to hours.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* Duration.to.hours(Duration.minutes(90)); // 1.5
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
hours: (d) => Brand.unwrap(d) / (60 * 60 * 1e3),
|
|
146
|
+
/**
|
|
147
|
+
* Converts a Duration to days.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* Duration.to.days(Duration.hours(36)); // 1.5
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
days: (d) => Brand.unwrap(d) / (24 * 60 * 60 * 1e3)
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* Adds two Durations together.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
add: (other) => (self) => wrap(Brand.unwrap(self) + Brand.unwrap(other)),
|
|
165
|
+
/**
|
|
166
|
+
* Subtracts the other Duration from this one.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
subtract: (other) => (self) => wrap(Brand.unwrap(self) - Brand.unwrap(other))
|
|
174
|
+
};
|
|
56
175
|
|
|
57
176
|
// src/Types/RetryPolicy.ts
|
|
58
|
-
var RetryPolicy
|
|
59
|
-
|
|
60
|
-
|
|
177
|
+
var RetryPolicy = {
|
|
178
|
+
/**
|
|
179
|
+
* Creates a RetryPolicy with a constant delay between retry attempts.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const policy = RetryPolicy.constant({
|
|
184
|
+
* attempts: 3,
|
|
185
|
+
* delay: Duration.seconds(1),
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
constant: (options) => ({
|
|
61
190
|
attempts: Math.max(1, options.attempts),
|
|
62
191
|
getDelay: () => options.delay
|
|
63
|
-
})
|
|
64
|
-
|
|
192
|
+
}),
|
|
193
|
+
/**
|
|
194
|
+
* Creates a RetryPolicy with exponential backoff delays between attempts.
|
|
195
|
+
* An optional `factor` (default 2) controls the growth rate.
|
|
196
|
+
* An optional `jitter` (default false) adds randomized variance to prevent thundering herd problems.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const policy = RetryPolicy.exponential({
|
|
201
|
+
* attempts: 5,
|
|
202
|
+
* initial: Duration.milliseconds(100),
|
|
203
|
+
* factor: 2,
|
|
204
|
+
* jitter: true,
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
exponential: (options) => {
|
|
65
209
|
const attempts = Math.max(1, options.attempts);
|
|
66
210
|
const initialMs = Duration.to.milliseconds(options.initial);
|
|
67
211
|
const factor = options.factor ?? 2;
|
|
@@ -74,8 +218,8 @@ var RetryPolicy;
|
|
|
74
218
|
return Duration.milliseconds(finalMs);
|
|
75
219
|
}
|
|
76
220
|
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
79
223
|
// Annotate the CommonJS export names for ESM import in node:
|
|
80
224
|
0 && (module.exports = {
|
|
81
225
|
Brand,
|
package/dist/types.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as Duration } from './Duration-
|
|
2
|
-
export { B as Brand } from './Duration-
|
|
1
|
+
import { D as Duration } from './Duration-DeyxG6VQ.cjs';
|
|
2
|
+
export { B as Brand } from './Duration-DeyxG6VQ.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* An immutable policy describing retry limits and backoff delay strategies.
|
|
@@ -16,7 +16,7 @@ type RetryPolicy = {
|
|
|
16
16
|
readonly attempts: number;
|
|
17
17
|
readonly getDelay: (attempt: number) => Duration;
|
|
18
18
|
};
|
|
19
|
-
declare
|
|
19
|
+
declare const RetryPolicy: {
|
|
20
20
|
/**
|
|
21
21
|
* Creates a RetryPolicy with a constant delay between retry attempts.
|
|
22
22
|
*
|
|
@@ -28,7 +28,7 @@ declare namespace RetryPolicy {
|
|
|
28
28
|
* });
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
constant: (options: {
|
|
32
32
|
attempts: number;
|
|
33
33
|
delay: Duration;
|
|
34
34
|
}) => RetryPolicy;
|
|
@@ -47,12 +47,12 @@ declare namespace RetryPolicy {
|
|
|
47
47
|
* });
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
exponential: (options: {
|
|
51
51
|
attempts: number;
|
|
52
52
|
initial: Duration;
|
|
53
53
|
factor?: number;
|
|
54
54
|
jitter?: boolean;
|
|
55
55
|
}) => RetryPolicy;
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
|
|
58
58
|
export { Duration, RetryPolicy };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as Duration } from './Duration-
|
|
2
|
-
export { B as Brand } from './Duration-
|
|
1
|
+
import { D as Duration } from './Duration-DeyxG6VQ.js';
|
|
2
|
+
export { B as Brand } from './Duration-DeyxG6VQ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* An immutable policy describing retry limits and backoff delay strategies.
|
|
@@ -16,7 +16,7 @@ type RetryPolicy = {
|
|
|
16
16
|
readonly attempts: number;
|
|
17
17
|
readonly getDelay: (attempt: number) => Duration;
|
|
18
18
|
};
|
|
19
|
-
declare
|
|
19
|
+
declare const RetryPolicy: {
|
|
20
20
|
/**
|
|
21
21
|
* Creates a RetryPolicy with a constant delay between retry attempts.
|
|
22
22
|
*
|
|
@@ -28,7 +28,7 @@ declare namespace RetryPolicy {
|
|
|
28
28
|
* });
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
constant: (options: {
|
|
32
32
|
attempts: number;
|
|
33
33
|
delay: Duration;
|
|
34
34
|
}) => RetryPolicy;
|
|
@@ -47,12 +47,12 @@ declare namespace RetryPolicy {
|
|
|
47
47
|
* });
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
exponential: (options: {
|
|
51
51
|
attempts: number;
|
|
52
52
|
initial: Duration;
|
|
53
53
|
factor?: number;
|
|
54
54
|
jitter?: boolean;
|
|
55
55
|
}) => RetryPolicy;
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
|
|
58
58
|
export { Duration, RetryPolicy };
|
package/dist/types.mjs
CHANGED
|
@@ -1,39 +1,183 @@
|
|
|
1
1
|
// src/Types/Brand.ts
|
|
2
|
-
var Brand
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var Brand = {
|
|
3
|
+
/**
|
|
4
|
+
* Returns a constructor that wraps a value of type T in brand K.
|
|
5
|
+
* The resulting function performs an unchecked cast — only use when the raw
|
|
6
|
+
* value is known to satisfy the brand's invariants.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* type PositiveNumber = Brand<"PositiveNumber", number>;
|
|
11
|
+
* const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
|
|
12
|
+
*
|
|
13
|
+
* const n: PositiveNumber = toPositiveNumber(42);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
wrap: () => (value) => value,
|
|
17
|
+
/**
|
|
18
|
+
* Strips the brand and returns the underlying value.
|
|
19
|
+
* Since Brand<K, T> extends T this is rarely needed, but can improve readability.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* type UserId = Brand<"UserId", string>;
|
|
24
|
+
* const toUserId = Brand.wrap<"UserId", string>();
|
|
25
|
+
* const userId: UserId = toUserId("user-123");
|
|
26
|
+
* const raw: string = Brand.unwrap(userId); // "user-123"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
unwrap: (branded) => branded
|
|
30
|
+
};
|
|
7
31
|
|
|
8
32
|
// src/Types/Duration.ts
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
var wrap = Brand.wrap();
|
|
34
|
+
var Duration = {
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Duration from milliseconds.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* Duration.milliseconds(500); // 500ms Duration
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
milliseconds: (ms) => wrap(ms),
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Duration from seconds.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* Duration.seconds(2); // 2000ms Duration
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
seconds: (s) => wrap(s * 1e3),
|
|
53
|
+
/**
|
|
54
|
+
* Creates a Duration from minutes.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* Duration.minutes(5); // 300000ms Duration
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
minutes: (m) => wrap(m * 60 * 1e3),
|
|
62
|
+
/**
|
|
63
|
+
* Creates a Duration from hours.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* Duration.hours(1); // 3600000ms Duration
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
hours: (h) => wrap(h * 60 * 60 * 1e3),
|
|
71
|
+
/**
|
|
72
|
+
* Creates a Duration from days.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* Duration.days(1); // 86400000ms Duration
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
days: (d) => wrap(d * 24 * 60 * 60 * 1e3),
|
|
80
|
+
// --- to ---
|
|
81
|
+
to: {
|
|
82
|
+
/**
|
|
83
|
+
* Converts a Duration back to raw milliseconds.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* Duration.to.milliseconds(Duration.seconds(2)); // 2000
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
milliseconds: (d) => Brand.unwrap(d),
|
|
91
|
+
/**
|
|
92
|
+
* Converts a Duration to seconds.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* Duration.to.seconds(Duration.milliseconds(2500)); // 2.5
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
seconds: (d) => Brand.unwrap(d) / 1e3,
|
|
100
|
+
/**
|
|
101
|
+
* Converts a Duration to minutes.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* Duration.to.minutes(Duration.seconds(120)); // 2
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
minutes: (d) => Brand.unwrap(d) / (60 * 1e3),
|
|
109
|
+
/**
|
|
110
|
+
* Converts a Duration to hours.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* Duration.to.hours(Duration.minutes(90)); // 1.5
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
hours: (d) => Brand.unwrap(d) / (60 * 60 * 1e3),
|
|
118
|
+
/**
|
|
119
|
+
* Converts a Duration to days.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* Duration.to.days(Duration.hours(36)); // 1.5
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
days: (d) => Brand.unwrap(d) / (24 * 60 * 60 * 1e3)
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Adds two Durations together.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
add: (other) => (self) => wrap(Brand.unwrap(self) + Brand.unwrap(other)),
|
|
137
|
+
/**
|
|
138
|
+
* Subtracts the other Duration from this one.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
subtract: (other) => (self) => wrap(Brand.unwrap(self) - Brand.unwrap(other))
|
|
146
|
+
};
|
|
28
147
|
|
|
29
148
|
// src/Types/RetryPolicy.ts
|
|
30
|
-
var RetryPolicy
|
|
31
|
-
|
|
32
|
-
|
|
149
|
+
var RetryPolicy = {
|
|
150
|
+
/**
|
|
151
|
+
* Creates a RetryPolicy with a constant delay between retry attempts.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const policy = RetryPolicy.constant({
|
|
156
|
+
* attempts: 3,
|
|
157
|
+
* delay: Duration.seconds(1),
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
constant: (options) => ({
|
|
33
162
|
attempts: Math.max(1, options.attempts),
|
|
34
163
|
getDelay: () => options.delay
|
|
35
|
-
})
|
|
36
|
-
|
|
164
|
+
}),
|
|
165
|
+
/**
|
|
166
|
+
* Creates a RetryPolicy with exponential backoff delays between attempts.
|
|
167
|
+
* An optional `factor` (default 2) controls the growth rate.
|
|
168
|
+
* An optional `jitter` (default false) adds randomized variance to prevent thundering herd problems.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const policy = RetryPolicy.exponential({
|
|
173
|
+
* attempts: 5,
|
|
174
|
+
* initial: Duration.milliseconds(100),
|
|
175
|
+
* factor: 2,
|
|
176
|
+
* jitter: true,
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
exponential: (options) => {
|
|
37
181
|
const attempts = Math.max(1, options.attempts);
|
|
38
182
|
const initialMs = Duration.to.milliseconds(options.initial);
|
|
39
183
|
const factor = options.factor ?? 2;
|
|
@@ -46,8 +190,8 @@ var RetryPolicy;
|
|
|
46
190
|
return Duration.milliseconds(finalMs);
|
|
47
191
|
}
|
|
48
192
|
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
51
195
|
export {
|
|
52
196
|
Brand,
|
|
53
197
|
Duration,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nlozgachev/pipelined",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Opinionated functional abstractions for TypeScript",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://pipelined.lozgachev.dev",
|
|
@@ -84,17 +84,16 @@
|
|
|
84
84
|
"lint": "oxlint src/",
|
|
85
85
|
"format": "dprint fmt && dprint fmt --config dprint.md.json \"docs/**/*.md\" \"docs/**/*.mdx\" \"README.md\"",
|
|
86
86
|
"format:check": "dprint check && dprint check --config dprint.md.json \"docs/**/*.md\" \"docs/**/*.mdx\" \"README.md\"",
|
|
87
|
-
"release:patch": "bumpp --patch -c -t -p",
|
|
88
|
-
"release:minor": "bumpp --minor -c -t -p",
|
|
89
87
|
"docs:dev": "pnpm --filter pipelined-docs dev",
|
|
90
88
|
"docs:build": "pnpm --filter pipelined-docs build"
|
|
91
89
|
},
|
|
92
90
|
"devDependencies": {
|
|
91
|
+
"@size-limit/esbuild": "13.0.3",
|
|
93
92
|
"@size-limit/file": "13.0.3",
|
|
94
93
|
"@types/node": "26.2.0",
|
|
95
94
|
"@vitest/coverage-v8": "4.1.10",
|
|
96
|
-
"bumpp": "12.2.0",
|
|
97
95
|
"dprint": "0.55.2",
|
|
96
|
+
"esbuild": "0.28.2",
|
|
98
97
|
"fast-check": "4.9.0",
|
|
99
98
|
"oxlint": "1.78.0",
|
|
100
99
|
"size-limit": "13.0.3",
|
|
@@ -104,28 +103,40 @@
|
|
|
104
103
|
},
|
|
105
104
|
"size-limit": [
|
|
106
105
|
{
|
|
106
|
+
"name": "Index (Monolithic import *)",
|
|
107
|
+
"import": "*",
|
|
107
108
|
"path": "dist/index.mjs",
|
|
108
|
-
"limit": "
|
|
109
|
-
"gzip": true
|
|
109
|
+
"limit": "18 KB",
|
|
110
|
+
"gzip": true,
|
|
111
|
+
"ignore": ["util", "node:util"]
|
|
110
112
|
},
|
|
111
113
|
{
|
|
114
|
+
"name": "Core (import * as Core)",
|
|
115
|
+
"import": "*",
|
|
112
116
|
"path": "dist/core.mjs",
|
|
113
|
-
"limit": "
|
|
117
|
+
"limit": "11 KB",
|
|
114
118
|
"gzip": true
|
|
115
119
|
},
|
|
116
120
|
{
|
|
117
|
-
"
|
|
118
|
-
"
|
|
121
|
+
"name": "Data (import * as Data)",
|
|
122
|
+
"import": "*",
|
|
123
|
+
"path": "dist/data.mjs",
|
|
124
|
+
"limit": "7 KB",
|
|
119
125
|
"gzip": true
|
|
120
126
|
},
|
|
121
127
|
{
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
128
|
+
"name": "Composition (import * as Composition)",
|
|
129
|
+
"import": "*",
|
|
130
|
+
"path": "dist/composition.mjs",
|
|
131
|
+
"limit": "2 KB",
|
|
132
|
+
"gzip": true,
|
|
133
|
+
"ignore": ["util", "node:util"]
|
|
125
134
|
},
|
|
126
135
|
{
|
|
136
|
+
"name": "Types (import * as Types)",
|
|
137
|
+
"import": "*",
|
|
127
138
|
"path": "dist/types.mjs",
|
|
128
|
-
"limit": "
|
|
139
|
+
"limit": "400 B",
|
|
129
140
|
"gzip": true
|
|
130
141
|
}
|
|
131
142
|
],
|