@nlozgachev/pipelined 0.63.0 → 0.65.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/types.cjs CHANGED
@@ -1,228 +1,198 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/Types/Brand.ts
3
+ const Brand = {
4
+ /**
5
+ * Returns a constructor that wraps a value of type T in brand K.
6
+ * The resulting function performs an unchecked cast — only use when the raw
7
+ * value is known to satisfy the brand's invariants.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * type PositiveNumber = Brand<"PositiveNumber", number>;
12
+ * const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
13
+ *
14
+ * const n: PositiveNumber = toPositiveNumber(42);
15
+ * ```
16
+ */
17
+ wrap: () => (value) => value,
18
+ /**
19
+ * Strips the brand and returns the underlying value.
20
+ * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * type UserId = Brand<"UserId", string>;
25
+ * const toUserId = Brand.wrap<"UserId", string>();
26
+ * const userId: UserId = toUserId("user-123");
27
+ * const raw: string = Brand.unwrap(userId); // "user-123"
28
+ * ```
29
+ */
30
+ unwrap: (branded) => branded
9
31
  };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
32
+ //#endregion
33
+ //#region src/Types/RetryPolicy.ts
34
+ const RetryPolicy = {
35
+ /**
36
+ * Creates a RetryPolicy with a constant delay between retry attempts.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const policy = RetryPolicy.constant({
41
+ * attempts: 3,
42
+ * delay: Duration.seconds(1),
43
+ * });
44
+ * ```
45
+ */
46
+ constant: (options) => ({
47
+ attempts: Math.max(1, options.attempts),
48
+ getDelay: () => options.delay
49
+ }),
50
+ /**
51
+ * Creates a RetryPolicy with exponential backoff delays between attempts.
52
+ * An optional `factor` (default 2) controls the growth rate.
53
+ * An optional `jitter` (default false) adds randomized variance to prevent thundering herd problems.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const policy = RetryPolicy.exponential({
58
+ * attempts: 5,
59
+ * initial: Duration.milliseconds(100),
60
+ * factor: 2,
61
+ * jitter: true,
62
+ * });
63
+ * ```
64
+ */
65
+ exponential: (options) => {
66
+ const attempts = Math.max(1, options.attempts);
67
+ const initialMs = Duration.to.milliseconds(options.initial);
68
+ const factor = options.factor ?? 2;
69
+ const jitter = options.jitter ?? false;
70
+ return {
71
+ attempts,
72
+ getDelay: (attempt) => {
73
+ const rawMs = initialMs * factor ** Math.max(0, attempt - 1);
74
+ const finalMs = jitter ? Math.random() * rawMs : rawMs;
75
+ return Duration.milliseconds(finalMs);
76
+ }
77
+ };
78
+ }
17
79
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/Types/index.ts
21
- var Types_exports = {};
22
- __export(Types_exports, {
23
- Brand: () => Brand,
24
- Duration: () => Duration,
25
- RetryPolicy: () => RetryPolicy
26
- });
27
- module.exports = __toCommonJS(Types_exports);
28
-
29
- // src/Types/Brand.ts
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
80
+ //#endregion
81
+ //#region src/Types/Duration.ts
82
+ const wrap = Brand.wrap();
83
+ const Duration = {
84
+ /**
85
+ * Creates a Duration from milliseconds.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * Duration.milliseconds(500); // 500ms Duration
90
+ * ```
91
+ */
92
+ milliseconds: (ms) => wrap(ms),
93
+ /**
94
+ * Creates a Duration from seconds.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * Duration.seconds(2); // 2000ms Duration
99
+ * ```
100
+ */
101
+ seconds: (s) => wrap(s * 1e3),
102
+ /**
103
+ * Creates a Duration from minutes.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * Duration.minutes(5); // 300000ms Duration
108
+ * ```
109
+ */
110
+ minutes: (m) => wrap(m * 60 * 1e3),
111
+ /**
112
+ * Creates a Duration from hours.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * Duration.hours(1); // 3600000ms Duration
117
+ * ```
118
+ */
119
+ hours: (h) => wrap(h * 60 * 60 * 1e3),
120
+ /**
121
+ * Creates a Duration from days.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * Duration.days(1); // 86400000ms Duration
126
+ * ```
127
+ */
128
+ days: (d) => wrap(d * 24 * 60 * 60 * 1e3),
129
+ to: {
130
+ /**
131
+ * Converts a Duration back to raw milliseconds.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * Duration.to.milliseconds(Duration.seconds(2)); // 2000
136
+ * ```
137
+ */
138
+ milliseconds: (d) => Brand.unwrap(d),
139
+ /**
140
+ * Converts a Duration to seconds.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * Duration.to.seconds(Duration.milliseconds(2500)); // 2.5
145
+ * ```
146
+ */
147
+ seconds: (d) => Brand.unwrap(d) / 1e3,
148
+ /**
149
+ * Converts a Duration to minutes.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * Duration.to.minutes(Duration.seconds(120)); // 2
154
+ * ```
155
+ */
156
+ minutes: (d) => Brand.unwrap(d) / 6e4,
157
+ /**
158
+ * Converts a Duration to hours.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * Duration.to.hours(Duration.minutes(90)); // 1.5
163
+ * ```
164
+ */
165
+ hours: (d) => Brand.unwrap(d) / 36e5,
166
+ /**
167
+ * Converts a Duration to days.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * Duration.to.days(Duration.hours(36)); // 1.5
172
+ * ```
173
+ */
174
+ days: (d) => Brand.unwrap(d) / 864e5
175
+ },
176
+ /**
177
+ * Adds two Durations together.
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
182
+ * ```
183
+ */
184
+ add: (other) => (self) => wrap(Brand.unwrap(self) + Brand.unwrap(other)),
185
+ /**
186
+ * Subtracts the other Duration from this one.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
191
+ * ```
192
+ */
193
+ subtract: (other) => (self) => wrap(Brand.unwrap(self) - Brand.unwrap(other))
58
194
  };
59
-
60
- // src/Types/Duration.ts
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
- };
175
-
176
- // src/Types/RetryPolicy.ts
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) => ({
190
- attempts: Math.max(1, options.attempts),
191
- getDelay: () => options.delay
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) => {
209
- const attempts = Math.max(1, options.attempts);
210
- const initialMs = Duration.to.milliseconds(options.initial);
211
- const factor = options.factor ?? 2;
212
- const jitter = options.jitter ?? false;
213
- return {
214
- attempts,
215
- getDelay: (attempt) => {
216
- const rawMs = initialMs * factor ** Math.max(0, attempt - 1);
217
- const finalMs = jitter ? Math.random() * rawMs : rawMs;
218
- return Duration.milliseconds(finalMs);
219
- }
220
- };
221
- }
222
- };
223
- // Annotate the CommonJS export names for ESM import in node:
224
- 0 && (module.exports = {
225
- Brand,
226
- Duration,
227
- RetryPolicy
228
- });
195
+ //#endregion
196
+ exports.Brand = Brand;
197
+ exports.Duration = Duration;
198
+ exports.RetryPolicy = RetryPolicy;
package/dist/types.d.cts CHANGED
@@ -1,58 +1,2 @@
1
- import { D as Duration } from './Duration-DeyxG6VQ.cjs';
2
- export { B as Brand } from './Duration-DeyxG6VQ.cjs';
3
-
4
- /**
5
- * An immutable policy describing retry limits and backoff delay strategies.
6
- *
7
- * @example
8
- * ```ts
9
- * const policy: RetryPolicy = RetryPolicy.constant({
10
- * attempts: 3,
11
- * delay: Duration.seconds(1),
12
- * });
13
- * ```
14
- */
15
- type RetryPolicy = {
16
- readonly attempts: number;
17
- readonly getDelay: (attempt: number) => Duration;
18
- };
19
- declare const RetryPolicy: {
20
- /**
21
- * Creates a RetryPolicy with a constant delay between retry attempts.
22
- *
23
- * @example
24
- * ```ts
25
- * const policy = RetryPolicy.constant({
26
- * attempts: 3,
27
- * delay: Duration.seconds(1),
28
- * });
29
- * ```
30
- */
31
- constant: (options: {
32
- attempts: number;
33
- delay: Duration;
34
- }) => RetryPolicy;
35
- /**
36
- * Creates a RetryPolicy with exponential backoff delays between attempts.
37
- * An optional `factor` (default 2) controls the growth rate.
38
- * An optional `jitter` (default false) adds randomized variance to prevent thundering herd problems.
39
- *
40
- * @example
41
- * ```ts
42
- * const policy = RetryPolicy.exponential({
43
- * attempts: 5,
44
- * initial: Duration.milliseconds(100),
45
- * factor: 2,
46
- * jitter: true,
47
- * });
48
- * ```
49
- */
50
- exponential: (options: {
51
- attempts: number;
52
- initial: Duration;
53
- factor?: number;
54
- jitter?: boolean;
55
- }) => RetryPolicy;
56
- };
57
-
58
- export { Duration, RetryPolicy };
1
+ import { n as Duration, r as Brand, t as RetryPolicy } from "./index-Bs8En5LJ.cjs";
2
+ export { Brand, Duration, RetryPolicy };
package/dist/types.d.ts CHANGED
@@ -1,58 +1,2 @@
1
- import { D as Duration } from './Duration-DeyxG6VQ.js';
2
- export { B as Brand } from './Duration-DeyxG6VQ.js';
3
-
4
- /**
5
- * An immutable policy describing retry limits and backoff delay strategies.
6
- *
7
- * @example
8
- * ```ts
9
- * const policy: RetryPolicy = RetryPolicy.constant({
10
- * attempts: 3,
11
- * delay: Duration.seconds(1),
12
- * });
13
- * ```
14
- */
15
- type RetryPolicy = {
16
- readonly attempts: number;
17
- readonly getDelay: (attempt: number) => Duration;
18
- };
19
- declare const RetryPolicy: {
20
- /**
21
- * Creates a RetryPolicy with a constant delay between retry attempts.
22
- *
23
- * @example
24
- * ```ts
25
- * const policy = RetryPolicy.constant({
26
- * attempts: 3,
27
- * delay: Duration.seconds(1),
28
- * });
29
- * ```
30
- */
31
- constant: (options: {
32
- attempts: number;
33
- delay: Duration;
34
- }) => RetryPolicy;
35
- /**
36
- * Creates a RetryPolicy with exponential backoff delays between attempts.
37
- * An optional `factor` (default 2) controls the growth rate.
38
- * An optional `jitter` (default false) adds randomized variance to prevent thundering herd problems.
39
- *
40
- * @example
41
- * ```ts
42
- * const policy = RetryPolicy.exponential({
43
- * attempts: 5,
44
- * initial: Duration.milliseconds(100),
45
- * factor: 2,
46
- * jitter: true,
47
- * });
48
- * ```
49
- */
50
- exponential: (options: {
51
- attempts: number;
52
- initial: Duration;
53
- factor?: number;
54
- jitter?: boolean;
55
- }) => RetryPolicy;
56
- };
57
-
58
- export { Duration, RetryPolicy };
1
+ import { n as Duration, r as Brand, t as RetryPolicy } from "./index-Bs8En5LJ.js";
2
+ export { Brand, Duration, RetryPolicy };