@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.
@@ -1,181 +0,0 @@
1
- declare const _brand: unique symbol;
2
- /**
3
- * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
4
- * Prevents accidentally mixing up values that share the same underlying type.
5
- *
6
- * @example
7
- * ```ts
8
- * type UserId = Brand<"UserId", string>;
9
- * type ProductId = Brand<"ProductId", string>;
10
- *
11
- * const toUserId = Brand.wrap<"UserId", string>();
12
- * const toProductId = Brand.wrap<"ProductId", string>();
13
- *
14
- * const userId: UserId = toUserId("user-123");
15
- * const productId: ProductId = toProductId("prod-456");
16
- *
17
- * // Type error: ProductId is not assignable to UserId
18
- * // const wrong: UserId = productId;
19
- * ```
20
- */
21
- type Brand<K extends string, T> = T & {
22
- readonly [_brand]: K;
23
- };
24
- declare const Brand: {
25
- /**
26
- * Returns a constructor that wraps a value of type T in brand K.
27
- * The resulting function performs an unchecked cast — only use when the raw
28
- * value is known to satisfy the brand's invariants.
29
- *
30
- * @example
31
- * ```ts
32
- * type PositiveNumber = Brand<"PositiveNumber", number>;
33
- * const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
34
- *
35
- * const n: PositiveNumber = toPositiveNumber(42);
36
- * ```
37
- */
38
- wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
39
- /**
40
- * Strips the brand and returns the underlying value.
41
- * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
42
- *
43
- * @example
44
- * ```ts
45
- * type UserId = Brand<"UserId", string>;
46
- * const toUserId = Brand.wrap<"UserId", string>();
47
- * const userId: UserId = toUserId("user-123");
48
- * const raw: string = Brand.unwrap(userId); // "user-123"
49
- * ```
50
- */
51
- unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
52
- };
53
-
54
- /**
55
- * A branded nominal type representing a duration of time in milliseconds.
56
- * Use Duration to ensure safe time-based operators and clear unit conversions.
57
- *
58
- * @example
59
- * ```ts
60
- * const halfSecond = Duration.milliseconds(500);
61
- * const twoSeconds = Duration.seconds(2);
62
- * const total = pipe(halfSecond, Duration.add(twoSeconds));
63
- *
64
- * Duration.to.seconds(total); // 2.5
65
- * ```
66
- */
67
- type Duration = Brand<"Duration", number>;
68
- declare const Duration: {
69
- /**
70
- * Creates a Duration from milliseconds.
71
- *
72
- * @example
73
- * ```ts
74
- * Duration.milliseconds(500); // 500ms Duration
75
- * ```
76
- */
77
- milliseconds: (ms: number) => Duration;
78
- /**
79
- * Creates a Duration from seconds.
80
- *
81
- * @example
82
- * ```ts
83
- * Duration.seconds(2); // 2000ms Duration
84
- * ```
85
- */
86
- seconds: (s: number) => Duration;
87
- /**
88
- * Creates a Duration from minutes.
89
- *
90
- * @example
91
- * ```ts
92
- * Duration.minutes(5); // 300000ms Duration
93
- * ```
94
- */
95
- minutes: (m: number) => Duration;
96
- /**
97
- * Creates a Duration from hours.
98
- *
99
- * @example
100
- * ```ts
101
- * Duration.hours(1); // 3600000ms Duration
102
- * ```
103
- */
104
- hours: (h: number) => Duration;
105
- /**
106
- * Creates a Duration from days.
107
- *
108
- * @example
109
- * ```ts
110
- * Duration.days(1); // 86400000ms Duration
111
- * ```
112
- */
113
- days: (d: number) => Duration;
114
- to: {
115
- /**
116
- * Converts a Duration back to raw milliseconds.
117
- *
118
- * @example
119
- * ```ts
120
- * Duration.to.milliseconds(Duration.seconds(2)); // 2000
121
- * ```
122
- */
123
- milliseconds: (d: Duration) => number;
124
- /**
125
- * Converts a Duration to seconds.
126
- *
127
- * @example
128
- * ```ts
129
- * Duration.to.seconds(Duration.milliseconds(2500)); // 2.5
130
- * ```
131
- */
132
- seconds: (d: Duration) => number;
133
- /**
134
- * Converts a Duration to minutes.
135
- *
136
- * @example
137
- * ```ts
138
- * Duration.to.minutes(Duration.seconds(120)); // 2
139
- * ```
140
- */
141
- minutes: (d: Duration) => number;
142
- /**
143
- * Converts a Duration to hours.
144
- *
145
- * @example
146
- * ```ts
147
- * Duration.to.hours(Duration.minutes(90)); // 1.5
148
- * ```
149
- */
150
- hours: (d: Duration) => number;
151
- /**
152
- * Converts a Duration to days.
153
- *
154
- * @example
155
- * ```ts
156
- * Duration.to.days(Duration.hours(36)); // 1.5
157
- * ```
158
- */
159
- days: (d: Duration) => number;
160
- };
161
- /**
162
- * Adds two Durations together.
163
- *
164
- * @example
165
- * ```ts
166
- * pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
167
- * ```
168
- */
169
- add: (other: Duration) => (self: Duration) => Duration;
170
- /**
171
- * Subtracts the other Duration from this one.
172
- *
173
- * @example
174
- * ```ts
175
- * pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
176
- * ```
177
- */
178
- subtract: (other: Duration) => (self: Duration) => Duration;
179
- };
180
-
181
- export { Brand as B, Duration as D };
@@ -1,142 +0,0 @@
1
- import { D as Duration } from './Duration-DeyxG6VQ.js';
2
-
3
- declare const _deferred: unique symbol;
4
- /**
5
- * A nominally typed, one-shot async value that supports `await` but enforces infallibility.
6
- *
7
- * Two design choices work together to make the guarantee structural rather than documentary:
8
- *
9
- * - The phantom `[_deferred]` symbol makes the type **nominal**: only values produced by
10
- * `Deferred.from.Promise` satisfy it. A plain object `{ then: ... }` does not.
11
- * - The single-parameter `.then()` **excludes rejection handlers** by construction. There is
12
- * no second argument to pass, so chaining and `.catch()` are impossible.
13
- *
14
- * This makes `Deferred<A>` the natural return type for `Task<A>`, which is guaranteed to
15
- * never reject.
16
- *
17
- * @example
18
- * ```ts
19
- * const value = await Deferred.from.Promise(Promise.resolve(42));
20
- * // value === 42
21
- * ```
22
- */
23
- type Deferred<A> = {
24
- readonly [_deferred]: A;
25
- readonly then: (onfulfilled: (value: A) => unknown) => void;
26
- };
27
- declare const Deferred: {
28
- from: {
29
- /**
30
- * Wraps a `Promise` or `Deferred` into a `Deferred`, structurally excluding rejection handlers,
31
- * `.catch()`, `.finally()`, and chainable `.then()`.
32
- *
33
- * **Precondition**: `p` must never reject. If `p` rejects, the returned `Deferred` will
34
- * never resolve — `await`-ing it will hang indefinitely. Use `Task.Result.tryCatch` to
35
- * handle operations that may fail before converting to a `Deferred`.
36
- *
37
- * @example
38
- * ```ts
39
- * const d = Deferred.from.Promise(Promise.resolve("hello"));
40
- * const value = await d; // "hello"
41
- * ```
42
- */
43
- Promise: <A>(p: Thenable<A>) => Deferred<A>;
44
- };
45
- to: {
46
- /**
47
- * Converts a `Deferred` back into a `Promise`.
48
- *
49
- * @example
50
- * ```ts
51
- * const p = Deferred.to.Promise(Deferred.from.Promise(Promise.resolve(42)));
52
- * // p is Promise<42>
53
- * ```
54
- */
55
- Promise: <A>(d: Deferred<A>) => globalThis.Promise<A>;
56
- };
57
- /**
58
- * Combines an array or tuple of `Deferred` values into a single `Deferred` of a tuple.
59
- * Resolves when all input `Deferred`s resolve.
60
- *
61
- * @example
62
- * ```ts
63
- * const [a, b] = await Deferred.all([d1, d2]);
64
- * ```
65
- */
66
- all: <T extends readonly Deferred<unknown>[]>(deferreds: T) => Deferred<{ [K in keyof T]: T[K] extends Deferred<infer A> ? A : never; }>;
67
- /**
68
- * Races multiple `Deferred` values and resolves with the first one to settle.
69
- *
70
- * @example
71
- * ```ts
72
- * const winner = await Deferred.race([d1, d2]);
73
- * ```
74
- */
75
- race: <A>(deferreds: ReadonlyArray<Deferred<A>>) => Deferred<A>;
76
- };
77
-
78
- /**
79
- * Represents a promise-like object or a deferred value that can be resolved with `.then()`.
80
- */
81
- type Thenable<A> = PromiseLike<A> | Deferred<A>;
82
- /**
83
- * Represents a value that can be either a synchronous value or a Thenable.
84
- */
85
- type Awaitable<A> = A | Thenable<A>;
86
- type NonEmptyArr<A> = readonly [A, ...A[]];
87
- type WithKind<K extends string> = {
88
- readonly kind: K;
89
- };
90
- type WithValue<T> = {
91
- readonly value: T;
92
- };
93
- type WithError<T> = {
94
- readonly error: T;
95
- };
96
- type WithErrors<T> = {
97
- readonly errors: NonEmptyArr<T>;
98
- };
99
- type WithFirst<T> = {
100
- readonly first: T;
101
- };
102
- type WithSecond<T> = {
103
- readonly second: T;
104
- };
105
- type WithLog<T> = {
106
- readonly log: ReadonlyArray<T>;
107
- };
108
- /** Retry policy for `Op.interpret`. */
109
- type RetryOptions<E> = {
110
- readonly attempts: number;
111
- readonly backoff?: Duration | ((attempt: number) => Duration);
112
- readonly when?: (error: E) => boolean;
113
- };
114
- /** Timeout policy for `Op.interpret`. Wraps the entire retry sequence. */
115
- type TimeoutOptions<E> = {
116
- readonly duration: Duration;
117
- readonly onTimeout: () => E;
118
- };
119
- type WithTimeout<E> = {
120
- readonly timeout?: TimeoutOptions<E>;
121
- };
122
- type WithDuration = {
123
- readonly duration: Duration;
124
- };
125
- type WithN = {
126
- readonly n: number;
127
- };
128
- type WithConcurrency = {
129
- readonly concurrency?: number;
130
- };
131
- type WithSize = {
132
- readonly size?: number;
133
- };
134
- type WithCooldown = {
135
- readonly cooldown?: Duration;
136
- };
137
- type WithMinInterval = {
138
- readonly minInterval?: Duration;
139
- };
140
- type NonEmpty<T extends string> = `NonEmpty${T}`;
141
-
142
- export { type Awaitable as A, Deferred as D, type NonEmpty as N, type RetryOptions as R, type Thenable as T, type WithConcurrency as W, type NonEmptyArr as a, type TimeoutOptions as b, type WithCooldown as c, type WithDuration as d, type WithError as e, type WithErrors as f, type WithFirst as g, type WithKind as h, type WithLog as i, type WithMinInterval as j, type WithN as k, type WithSecond as l, type WithSize as m, type WithTimeout as n, type WithValue as o };
@@ -1,142 +0,0 @@
1
- import { D as Duration } from './Duration-DeyxG6VQ.cjs';
2
-
3
- declare const _deferred: unique symbol;
4
- /**
5
- * A nominally typed, one-shot async value that supports `await` but enforces infallibility.
6
- *
7
- * Two design choices work together to make the guarantee structural rather than documentary:
8
- *
9
- * - The phantom `[_deferred]` symbol makes the type **nominal**: only values produced by
10
- * `Deferred.from.Promise` satisfy it. A plain object `{ then: ... }` does not.
11
- * - The single-parameter `.then()` **excludes rejection handlers** by construction. There is
12
- * no second argument to pass, so chaining and `.catch()` are impossible.
13
- *
14
- * This makes `Deferred<A>` the natural return type for `Task<A>`, which is guaranteed to
15
- * never reject.
16
- *
17
- * @example
18
- * ```ts
19
- * const value = await Deferred.from.Promise(Promise.resolve(42));
20
- * // value === 42
21
- * ```
22
- */
23
- type Deferred<A> = {
24
- readonly [_deferred]: A;
25
- readonly then: (onfulfilled: (value: A) => unknown) => void;
26
- };
27
- declare const Deferred: {
28
- from: {
29
- /**
30
- * Wraps a `Promise` or `Deferred` into a `Deferred`, structurally excluding rejection handlers,
31
- * `.catch()`, `.finally()`, and chainable `.then()`.
32
- *
33
- * **Precondition**: `p` must never reject. If `p` rejects, the returned `Deferred` will
34
- * never resolve — `await`-ing it will hang indefinitely. Use `Task.Result.tryCatch` to
35
- * handle operations that may fail before converting to a `Deferred`.
36
- *
37
- * @example
38
- * ```ts
39
- * const d = Deferred.from.Promise(Promise.resolve("hello"));
40
- * const value = await d; // "hello"
41
- * ```
42
- */
43
- Promise: <A>(p: Thenable<A>) => Deferred<A>;
44
- };
45
- to: {
46
- /**
47
- * Converts a `Deferred` back into a `Promise`.
48
- *
49
- * @example
50
- * ```ts
51
- * const p = Deferred.to.Promise(Deferred.from.Promise(Promise.resolve(42)));
52
- * // p is Promise<42>
53
- * ```
54
- */
55
- Promise: <A>(d: Deferred<A>) => globalThis.Promise<A>;
56
- };
57
- /**
58
- * Combines an array or tuple of `Deferred` values into a single `Deferred` of a tuple.
59
- * Resolves when all input `Deferred`s resolve.
60
- *
61
- * @example
62
- * ```ts
63
- * const [a, b] = await Deferred.all([d1, d2]);
64
- * ```
65
- */
66
- all: <T extends readonly Deferred<unknown>[]>(deferreds: T) => Deferred<{ [K in keyof T]: T[K] extends Deferred<infer A> ? A : never; }>;
67
- /**
68
- * Races multiple `Deferred` values and resolves with the first one to settle.
69
- *
70
- * @example
71
- * ```ts
72
- * const winner = await Deferred.race([d1, d2]);
73
- * ```
74
- */
75
- race: <A>(deferreds: ReadonlyArray<Deferred<A>>) => Deferred<A>;
76
- };
77
-
78
- /**
79
- * Represents a promise-like object or a deferred value that can be resolved with `.then()`.
80
- */
81
- type Thenable<A> = PromiseLike<A> | Deferred<A>;
82
- /**
83
- * Represents a value that can be either a synchronous value or a Thenable.
84
- */
85
- type Awaitable<A> = A | Thenable<A>;
86
- type NonEmptyArr<A> = readonly [A, ...A[]];
87
- type WithKind<K extends string> = {
88
- readonly kind: K;
89
- };
90
- type WithValue<T> = {
91
- readonly value: T;
92
- };
93
- type WithError<T> = {
94
- readonly error: T;
95
- };
96
- type WithErrors<T> = {
97
- readonly errors: NonEmptyArr<T>;
98
- };
99
- type WithFirst<T> = {
100
- readonly first: T;
101
- };
102
- type WithSecond<T> = {
103
- readonly second: T;
104
- };
105
- type WithLog<T> = {
106
- readonly log: ReadonlyArray<T>;
107
- };
108
- /** Retry policy for `Op.interpret`. */
109
- type RetryOptions<E> = {
110
- readonly attempts: number;
111
- readonly backoff?: Duration | ((attempt: number) => Duration);
112
- readonly when?: (error: E) => boolean;
113
- };
114
- /** Timeout policy for `Op.interpret`. Wraps the entire retry sequence. */
115
- type TimeoutOptions<E> = {
116
- readonly duration: Duration;
117
- readonly onTimeout: () => E;
118
- };
119
- type WithTimeout<E> = {
120
- readonly timeout?: TimeoutOptions<E>;
121
- };
122
- type WithDuration = {
123
- readonly duration: Duration;
124
- };
125
- type WithN = {
126
- readonly n: number;
127
- };
128
- type WithConcurrency = {
129
- readonly concurrency?: number;
130
- };
131
- type WithSize = {
132
- readonly size?: number;
133
- };
134
- type WithCooldown = {
135
- readonly cooldown?: Duration;
136
- };
137
- type WithMinInterval = {
138
- readonly minInterval?: Duration;
139
- };
140
- type NonEmpty<T extends string> = `NonEmpty${T}`;
141
-
142
- export { type Awaitable as A, Deferred as D, type NonEmpty as N, type RetryOptions as R, type Thenable as T, type WithConcurrency as W, type NonEmptyArr as a, type TimeoutOptions as b, type WithCooldown as c, type WithDuration as d, type WithError as e, type WithErrors as f, type WithFirst as g, type WithKind as h, type WithLog as i, type WithMinInterval as j, type WithN as k, type WithSecond as l, type WithSize as m, type WithTimeout as n, type WithValue as o };