@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 CHANGED
@@ -22,7 +22,7 @@ propagation, unhandled async rejections, race conditions, and verbose nested spr
22
22
  `Task.Result` for lazy infallible async, `Op` for declarative request concurrency, and `Stream` for
23
23
  typed event sequences.
24
24
 
25
- The library has zero external dependencies, <16 KB core gzipped (<25 KB total), and compiles to dual
25
+ The library has zero external dependencies, <11 KB core gzipped (<17 KB total), and compiles to dual
26
26
  ESM and CommonJS distributions.
27
27
 
28
28
  ## Documentation
@@ -550,13 +550,13 @@ if (Result.is.ok(email)) {
550
550
  `pipelined` is structured into 4 isolated, tree-shakeable entry points:
551
551
 
552
552
  - **`@nlozgachev/pipelined/core`**: Core context containers, async runtimes, optics, and logic
553
- abstractions (<16 KB gzipped).
553
+ abstractions (<11 KB gzipped).
554
554
  - **`@nlozgachev/pipelined/data`**: Curried, data-last utilities for collections, numbers, strings,
555
- and JSON (<10 KB gzipped).
555
+ and JSON (<7 KB gzipped).
556
556
  - **`@nlozgachev/pipelined/composition`**: Pure higher-order function combinators (`pipe`, `flow`,
557
557
  `compose`, `curry`, `uncurry`, `converge`, `juxt`, `memoize`, `tap`, `on`, `not`, `flip`, `fn`)
558
- (<3 KB gzipped).
559
- - **`@nlozgachev/pipelined/types`**: Type-level utilities (`Brand`, `Duration`, `RetryPolicy`) (<700
558
+ (<2 KB gzipped).
559
+ - **`@nlozgachev/pipelined/types`**: Type-level utilities (`Brand`, `Duration`, `RetryPolicy`) (<400
560
560
  B gzipped).
561
561
 
562
562
  Every utility in the library is benchmarked against its native equivalent. While currying introduces
@@ -21,7 +21,7 @@ declare const _brand: unique symbol;
21
21
  type Brand<K extends string, T> = T & {
22
22
  readonly [_brand]: K;
23
23
  };
24
- declare namespace Brand {
24
+ declare const Brand: {
25
25
  /**
26
26
  * Returns a constructor that wraps a value of type T in brand K.
27
27
  * The resulting function performs an unchecked cast — only use when the raw
@@ -35,7 +35,7 @@ declare namespace Brand {
35
35
  * const n: PositiveNumber = toPositiveNumber(42);
36
36
  * ```
37
37
  */
38
- const wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
38
+ wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
39
39
  /**
40
40
  * Strips the brand and returns the underlying value.
41
41
  * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
@@ -48,8 +48,8 @@ declare namespace Brand {
48
48
  * const raw: string = Brand.unwrap(userId); // "user-123"
49
49
  * ```
50
50
  */
51
- const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
52
- }
51
+ unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
52
+ };
53
53
 
54
54
  /**
55
55
  * A branded nominal type representing a duration of time in milliseconds.
@@ -65,7 +65,7 @@ declare namespace Brand {
65
65
  * ```
66
66
  */
67
67
  type Duration = Brand<"Duration", number>;
68
- declare namespace Duration {
68
+ declare const Duration: {
69
69
  /**
70
70
  * Creates a Duration from milliseconds.
71
71
  *
@@ -74,7 +74,7 @@ declare namespace Duration {
74
74
  * Duration.milliseconds(500); // 500ms Duration
75
75
  * ```
76
76
  */
77
- const milliseconds: (ms: number) => Duration;
77
+ milliseconds: (ms: number) => Duration;
78
78
  /**
79
79
  * Creates a Duration from seconds.
80
80
  *
@@ -83,7 +83,7 @@ declare namespace Duration {
83
83
  * Duration.seconds(2); // 2000ms Duration
84
84
  * ```
85
85
  */
86
- const seconds: (s: number) => Duration;
86
+ seconds: (s: number) => Duration;
87
87
  /**
88
88
  * Creates a Duration from minutes.
89
89
  *
@@ -92,7 +92,7 @@ declare namespace Duration {
92
92
  * Duration.minutes(5); // 300000ms Duration
93
93
  * ```
94
94
  */
95
- const minutes: (m: number) => Duration;
95
+ minutes: (m: number) => Duration;
96
96
  /**
97
97
  * Creates a Duration from hours.
98
98
  *
@@ -101,7 +101,7 @@ declare namespace Duration {
101
101
  * Duration.hours(1); // 3600000ms Duration
102
102
  * ```
103
103
  */
104
- const hours: (h: number) => Duration;
104
+ hours: (h: number) => Duration;
105
105
  /**
106
106
  * Creates a Duration from days.
107
107
  *
@@ -110,8 +110,8 @@ declare namespace Duration {
110
110
  * Duration.days(1); // 86400000ms Duration
111
111
  * ```
112
112
  */
113
- const days: (d: number) => Duration;
114
- namespace to {
113
+ days: (d: number) => Duration;
114
+ to: {
115
115
  /**
116
116
  * Converts a Duration back to raw milliseconds.
117
117
  *
@@ -120,7 +120,7 @@ declare namespace Duration {
120
120
  * Duration.to.milliseconds(Duration.seconds(2)); // 2000
121
121
  * ```
122
122
  */
123
- const milliseconds: (d: Duration) => number;
123
+ milliseconds: (d: Duration) => number;
124
124
  /**
125
125
  * Converts a Duration to seconds.
126
126
  *
@@ -129,7 +129,7 @@ declare namespace Duration {
129
129
  * Duration.to.seconds(Duration.milliseconds(2500)); // 2.5
130
130
  * ```
131
131
  */
132
- const seconds: (d: Duration) => number;
132
+ seconds: (d: Duration) => number;
133
133
  /**
134
134
  * Converts a Duration to minutes.
135
135
  *
@@ -138,7 +138,7 @@ declare namespace Duration {
138
138
  * Duration.to.minutes(Duration.seconds(120)); // 2
139
139
  * ```
140
140
  */
141
- const minutes: (d: Duration) => number;
141
+ minutes: (d: Duration) => number;
142
142
  /**
143
143
  * Converts a Duration to hours.
144
144
  *
@@ -147,7 +147,7 @@ declare namespace Duration {
147
147
  * Duration.to.hours(Duration.minutes(90)); // 1.5
148
148
  * ```
149
149
  */
150
- const hours: (d: Duration) => number;
150
+ hours: (d: Duration) => number;
151
151
  /**
152
152
  * Converts a Duration to days.
153
153
  *
@@ -156,8 +156,8 @@ declare namespace Duration {
156
156
  * Duration.to.days(Duration.hours(36)); // 1.5
157
157
  * ```
158
158
  */
159
- const days: (d: Duration) => number;
160
- }
159
+ days: (d: Duration) => number;
160
+ };
161
161
  /**
162
162
  * Adds two Durations together.
163
163
  *
@@ -166,7 +166,7 @@ declare namespace Duration {
166
166
  * pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
167
167
  * ```
168
168
  */
169
- const add: (other: Duration) => (self: Duration) => Duration;
169
+ add: (other: Duration) => (self: Duration) => Duration;
170
170
  /**
171
171
  * Subtracts the other Duration from this one.
172
172
  *
@@ -175,7 +175,7 @@ declare namespace Duration {
175
175
  * pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
176
176
  * ```
177
177
  */
178
- const subtract: (other: Duration) => (self: Duration) => Duration;
179
- }
178
+ subtract: (other: Duration) => (self: Duration) => Duration;
179
+ };
180
180
 
181
181
  export { Brand as B, Duration as D };
@@ -21,7 +21,7 @@ declare const _brand: unique symbol;
21
21
  type Brand<K extends string, T> = T & {
22
22
  readonly [_brand]: K;
23
23
  };
24
- declare namespace Brand {
24
+ declare const Brand: {
25
25
  /**
26
26
  * Returns a constructor that wraps a value of type T in brand K.
27
27
  * The resulting function performs an unchecked cast — only use when the raw
@@ -35,7 +35,7 @@ declare namespace Brand {
35
35
  * const n: PositiveNumber = toPositiveNumber(42);
36
36
  * ```
37
37
  */
38
- const wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
38
+ wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
39
39
  /**
40
40
  * Strips the brand and returns the underlying value.
41
41
  * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
@@ -48,8 +48,8 @@ declare namespace Brand {
48
48
  * const raw: string = Brand.unwrap(userId); // "user-123"
49
49
  * ```
50
50
  */
51
- const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
52
- }
51
+ unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
52
+ };
53
53
 
54
54
  /**
55
55
  * A branded nominal type representing a duration of time in milliseconds.
@@ -65,7 +65,7 @@ declare namespace Brand {
65
65
  * ```
66
66
  */
67
67
  type Duration = Brand<"Duration", number>;
68
- declare namespace Duration {
68
+ declare const Duration: {
69
69
  /**
70
70
  * Creates a Duration from milliseconds.
71
71
  *
@@ -74,7 +74,7 @@ declare namespace Duration {
74
74
  * Duration.milliseconds(500); // 500ms Duration
75
75
  * ```
76
76
  */
77
- const milliseconds: (ms: number) => Duration;
77
+ milliseconds: (ms: number) => Duration;
78
78
  /**
79
79
  * Creates a Duration from seconds.
80
80
  *
@@ -83,7 +83,7 @@ declare namespace Duration {
83
83
  * Duration.seconds(2); // 2000ms Duration
84
84
  * ```
85
85
  */
86
- const seconds: (s: number) => Duration;
86
+ seconds: (s: number) => Duration;
87
87
  /**
88
88
  * Creates a Duration from minutes.
89
89
  *
@@ -92,7 +92,7 @@ declare namespace Duration {
92
92
  * Duration.minutes(5); // 300000ms Duration
93
93
  * ```
94
94
  */
95
- const minutes: (m: number) => Duration;
95
+ minutes: (m: number) => Duration;
96
96
  /**
97
97
  * Creates a Duration from hours.
98
98
  *
@@ -101,7 +101,7 @@ declare namespace Duration {
101
101
  * Duration.hours(1); // 3600000ms Duration
102
102
  * ```
103
103
  */
104
- const hours: (h: number) => Duration;
104
+ hours: (h: number) => Duration;
105
105
  /**
106
106
  * Creates a Duration from days.
107
107
  *
@@ -110,8 +110,8 @@ declare namespace Duration {
110
110
  * Duration.days(1); // 86400000ms Duration
111
111
  * ```
112
112
  */
113
- const days: (d: number) => Duration;
114
- namespace to {
113
+ days: (d: number) => Duration;
114
+ to: {
115
115
  /**
116
116
  * Converts a Duration back to raw milliseconds.
117
117
  *
@@ -120,7 +120,7 @@ declare namespace Duration {
120
120
  * Duration.to.milliseconds(Duration.seconds(2)); // 2000
121
121
  * ```
122
122
  */
123
- const milliseconds: (d: Duration) => number;
123
+ milliseconds: (d: Duration) => number;
124
124
  /**
125
125
  * Converts a Duration to seconds.
126
126
  *
@@ -129,7 +129,7 @@ declare namespace Duration {
129
129
  * Duration.to.seconds(Duration.milliseconds(2500)); // 2.5
130
130
  * ```
131
131
  */
132
- const seconds: (d: Duration) => number;
132
+ seconds: (d: Duration) => number;
133
133
  /**
134
134
  * Converts a Duration to minutes.
135
135
  *
@@ -138,7 +138,7 @@ declare namespace Duration {
138
138
  * Duration.to.minutes(Duration.seconds(120)); // 2
139
139
  * ```
140
140
  */
141
- const minutes: (d: Duration) => number;
141
+ minutes: (d: Duration) => number;
142
142
  /**
143
143
  * Converts a Duration to hours.
144
144
  *
@@ -147,7 +147,7 @@ declare namespace Duration {
147
147
  * Duration.to.hours(Duration.minutes(90)); // 1.5
148
148
  * ```
149
149
  */
150
- const hours: (d: Duration) => number;
150
+ hours: (d: Duration) => number;
151
151
  /**
152
152
  * Converts a Duration to days.
153
153
  *
@@ -156,8 +156,8 @@ declare namespace Duration {
156
156
  * Duration.to.days(Duration.hours(36)); // 1.5
157
157
  * ```
158
158
  */
159
- const days: (d: Duration) => number;
160
- }
159
+ days: (d: Duration) => number;
160
+ };
161
161
  /**
162
162
  * Adds two Durations together.
163
163
  *
@@ -166,7 +166,7 @@ declare namespace Duration {
166
166
  * pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
167
167
  * ```
168
168
  */
169
- const add: (other: Duration) => (self: Duration) => Duration;
169
+ add: (other: Duration) => (self: Duration) => Duration;
170
170
  /**
171
171
  * Subtracts the other Duration from this one.
172
172
  *
@@ -175,7 +175,7 @@ declare namespace Duration {
175
175
  * pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
176
176
  * ```
177
177
  */
178
- const subtract: (other: Duration) => (self: Duration) => Duration;
179
- }
178
+ subtract: (other: Duration) => (self: Duration) => Duration;
179
+ };
180
180
 
181
181
  export { Brand as B, Duration as D };
@@ -1,4 +1,4 @@
1
- import { D as Duration } from './Duration-B8joKzro.js';
1
+ import { D as Duration } from './Duration-DeyxG6VQ.js';
2
2
 
3
3
  declare const _deferred: unique symbol;
4
4
  /**
@@ -24,8 +24,8 @@ type Deferred<A> = {
24
24
  readonly [_deferred]: A;
25
25
  readonly then: (onfulfilled: (value: A) => unknown) => void;
26
26
  };
27
- declare namespace Deferred {
28
- namespace from {
27
+ declare const Deferred: {
28
+ from: {
29
29
  /**
30
30
  * Wraps a `Promise` or `Deferred` into a `Deferred`, structurally excluding rejection handlers,
31
31
  * `.catch()`, `.finally()`, and chainable `.then()`.
@@ -40,9 +40,9 @@ declare namespace Deferred {
40
40
  * const value = await d; // "hello"
41
41
  * ```
42
42
  */
43
- const Promise: <A>(p: Thenable<A>) => Deferred<A>;
44
- }
45
- namespace to {
43
+ Promise: <A>(p: Thenable<A>) => Deferred<A>;
44
+ };
45
+ to: {
46
46
  /**
47
47
  * Converts a `Deferred` back into a `Promise`.
48
48
  *
@@ -52,8 +52,8 @@ declare namespace Deferred {
52
52
  * // p is Promise<42>
53
53
  * ```
54
54
  */
55
- const Promise: <A>(d: Deferred<A>) => globalThis.Promise<A>;
56
- }
55
+ Promise: <A>(d: Deferred<A>) => globalThis.Promise<A>;
56
+ };
57
57
  /**
58
58
  * Combines an array or tuple of `Deferred` values into a single `Deferred` of a tuple.
59
59
  * Resolves when all input `Deferred`s resolve.
@@ -63,7 +63,7 @@ declare namespace Deferred {
63
63
  * const [a, b] = await Deferred.all([d1, d2]);
64
64
  * ```
65
65
  */
66
- const all: <T extends readonly Deferred<unknown>[]>(deferreds: T) => Deferred<{ [K in keyof T]: T[K] extends Deferred<infer A> ? A : never; }>;
66
+ all: <T extends readonly Deferred<unknown>[]>(deferreds: T) => Deferred<{ [K in keyof T]: T[K] extends Deferred<infer A> ? A : never; }>;
67
67
  /**
68
68
  * Races multiple `Deferred` values and resolves with the first one to settle.
69
69
  *
@@ -72,8 +72,8 @@ declare namespace Deferred {
72
72
  * const winner = await Deferred.race([d1, d2]);
73
73
  * ```
74
74
  */
75
- const race: <A>(deferreds: ReadonlyArray<Deferred<A>>) => Deferred<A>;
76
- }
75
+ race: <A>(deferreds: ReadonlyArray<Deferred<A>>) => Deferred<A>;
76
+ };
77
77
 
78
78
  /**
79
79
  * Represents a promise-like object or a deferred value that can be resolved with `.then()`.
@@ -1,4 +1,4 @@
1
- import { D as Duration } from './Duration-B8joKzro.cjs';
1
+ import { D as Duration } from './Duration-DeyxG6VQ.cjs';
2
2
 
3
3
  declare const _deferred: unique symbol;
4
4
  /**
@@ -24,8 +24,8 @@ type Deferred<A> = {
24
24
  readonly [_deferred]: A;
25
25
  readonly then: (onfulfilled: (value: A) => unknown) => void;
26
26
  };
27
- declare namespace Deferred {
28
- namespace from {
27
+ declare const Deferred: {
28
+ from: {
29
29
  /**
30
30
  * Wraps a `Promise` or `Deferred` into a `Deferred`, structurally excluding rejection handlers,
31
31
  * `.catch()`, `.finally()`, and chainable `.then()`.
@@ -40,9 +40,9 @@ declare namespace Deferred {
40
40
  * const value = await d; // "hello"
41
41
  * ```
42
42
  */
43
- const Promise: <A>(p: Thenable<A>) => Deferred<A>;
44
- }
45
- namespace to {
43
+ Promise: <A>(p: Thenable<A>) => Deferred<A>;
44
+ };
45
+ to: {
46
46
  /**
47
47
  * Converts a `Deferred` back into a `Promise`.
48
48
  *
@@ -52,8 +52,8 @@ declare namespace Deferred {
52
52
  * // p is Promise<42>
53
53
  * ```
54
54
  */
55
- const Promise: <A>(d: Deferred<A>) => globalThis.Promise<A>;
56
- }
55
+ Promise: <A>(d: Deferred<A>) => globalThis.Promise<A>;
56
+ };
57
57
  /**
58
58
  * Combines an array or tuple of `Deferred` values into a single `Deferred` of a tuple.
59
59
  * Resolves when all input `Deferred`s resolve.
@@ -63,7 +63,7 @@ declare namespace Deferred {
63
63
  * const [a, b] = await Deferred.all([d1, d2]);
64
64
  * ```
65
65
  */
66
- const all: <T extends readonly Deferred<unknown>[]>(deferreds: T) => Deferred<{ [K in keyof T]: T[K] extends Deferred<infer A> ? A : never; }>;
66
+ all: <T extends readonly Deferred<unknown>[]>(deferreds: T) => Deferred<{ [K in keyof T]: T[K] extends Deferred<infer A> ? A : never; }>;
67
67
  /**
68
68
  * Races multiple `Deferred` values and resolves with the first one to settle.
69
69
  *
@@ -72,8 +72,8 @@ declare namespace Deferred {
72
72
  * const winner = await Deferred.race([d1, d2]);
73
73
  * ```
74
74
  */
75
- const race: <A>(deferreds: ReadonlyArray<Deferred<A>>) => Deferred<A>;
76
- }
75
+ race: <A>(deferreds: ReadonlyArray<Deferred<A>>) => Deferred<A>;
76
+ };
77
77
 
78
78
  /**
79
79
  * Represents a promise-like object or a deferred value that can be resolved with `.then()`.