@nlozgachev/pipelined 0.37.0 → 0.37.1

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/index.mjs CHANGED
@@ -28,12 +28,22 @@ import {
28
28
  uncurry3,
29
29
  uncurry4
30
30
  } from "./chunk-3Q5UBRYB.mjs";
31
+ import {
32
+ Arr,
33
+ Dict,
34
+ Num,
35
+ Rec,
36
+ Str,
37
+ Uniq
38
+ } from "./chunk-E7YI5PVW.mjs";
31
39
  import {
32
40
  Combinable,
41
+ Deferred,
33
42
  Equality,
34
43
  Lazy,
35
44
  Lens,
36
45
  Logged,
46
+ Maybe,
37
47
  Op,
38
48
  Optional,
39
49
  Ordering,
@@ -42,36 +52,21 @@ import {
42
52
  Refinement,
43
53
  RemoteData,
44
54
  Resource,
55
+ Result,
45
56
  State,
57
+ Task,
46
58
  TaskMaybe,
47
59
  TaskResult,
48
60
  TaskValidation,
49
61
  These,
50
62
  Tuple,
51
63
  Validation
52
- } from "./chunk-SHO53CQC.mjs";
53
- import {
54
- Arr,
55
- Dict,
56
- Num,
57
- Rec,
58
- Str,
59
- Uniq
60
- } from "./chunk-72BGUEQM.mjs";
61
- import {
62
- Deferred,
63
- Maybe,
64
- Result,
65
- Task
66
- } from "./chunk-PUMSVZB4.mjs";
67
- import "./chunk-IPP4XFYH.mjs";
68
- import {
69
- isNonEmptyList
70
- } from "./chunk-DBIC62UV.mjs";
64
+ } from "./chunk-M2X7TFKN.mjs";
71
65
  import {
72
66
  Brand,
73
- Duration
74
- } from "./chunk-VWVPHDZO.mjs";
67
+ Duration,
68
+ isNonEmptyList
69
+ } from "./chunk-5AFEEFE4.mjs";
75
70
  export {
76
71
  Arr,
77
72
  Brand,
package/dist/types.d.mts CHANGED
@@ -1,32 +1,3 @@
1
- /**
2
- * A list that is guaranteed to have at least one element.
3
- * Useful for ensuring functions receive non-empty input and for
4
- * accumulating errors in Validation.
5
- *
6
- * @example
7
- * ```ts
8
- * const errors: NonEmptyList<string> = ["First error", "Second error"];
9
- *
10
- * // TypeScript ensures at least one element:
11
- * const invalid: NonEmptyList<string> = []; // Error!
12
- * ```
13
- */
14
- type NonEmptyList<A> = readonly [A, ...A[]];
15
- /**
16
- * Type guard that checks if an array is non-empty.
17
- *
18
- * @example
19
- * ```ts
20
- * const items: string[] = getItems();
21
- *
22
- * if (isNonEmptyList(items)) {
23
- * // TypeScript knows items has at least one element
24
- * const first = items[0]; // string, not string | undefined
25
- * }
26
- * ```
27
- */
28
- declare const isNonEmptyList: <A>(list: readonly A[]) => list is NonEmptyList<A>;
29
-
30
1
  declare const _brand: unique symbol;
31
2
  /**
32
3
  * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
@@ -153,4 +124,33 @@ declare namespace Duration {
153
124
  const subtract: (other: Duration) => (self: Duration) => Duration;
154
125
  }
155
126
 
127
+ /**
128
+ * A list that is guaranteed to have at least one element.
129
+ * Useful for ensuring functions receive non-empty input and for
130
+ * accumulating errors in Validation.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const errors: NonEmptyList<string> = ["First error", "Second error"];
135
+ *
136
+ * // TypeScript ensures at least one element:
137
+ * const invalid: NonEmptyList<string> = []; // Error!
138
+ * ```
139
+ */
140
+ type NonEmptyList<A> = readonly [A, ...A[]];
141
+ /**
142
+ * Type guard that checks if an array is non-empty.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * const items: string[] = getItems();
147
+ *
148
+ * if (isNonEmptyList(items)) {
149
+ * // TypeScript knows items has at least one element
150
+ * const first = items[0]; // string, not string | undefined
151
+ * }
152
+ * ```
153
+ */
154
+ declare const isNonEmptyList: <A>(list: readonly A[]) => list is NonEmptyList<A>;
155
+
156
156
  export { Brand, Duration, type NonEmptyList, isNonEmptyList };
package/dist/types.d.ts CHANGED
@@ -1,32 +1,3 @@
1
- /**
2
- * A list that is guaranteed to have at least one element.
3
- * Useful for ensuring functions receive non-empty input and for
4
- * accumulating errors in Validation.
5
- *
6
- * @example
7
- * ```ts
8
- * const errors: NonEmptyList<string> = ["First error", "Second error"];
9
- *
10
- * // TypeScript ensures at least one element:
11
- * const invalid: NonEmptyList<string> = []; // Error!
12
- * ```
13
- */
14
- type NonEmptyList<A> = readonly [A, ...A[]];
15
- /**
16
- * Type guard that checks if an array is non-empty.
17
- *
18
- * @example
19
- * ```ts
20
- * const items: string[] = getItems();
21
- *
22
- * if (isNonEmptyList(items)) {
23
- * // TypeScript knows items has at least one element
24
- * const first = items[0]; // string, not string | undefined
25
- * }
26
- * ```
27
- */
28
- declare const isNonEmptyList: <A>(list: readonly A[]) => list is NonEmptyList<A>;
29
-
30
1
  declare const _brand: unique symbol;
31
2
  /**
32
3
  * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
@@ -153,4 +124,33 @@ declare namespace Duration {
153
124
  const subtract: (other: Duration) => (self: Duration) => Duration;
154
125
  }
155
126
 
127
+ /**
128
+ * A list that is guaranteed to have at least one element.
129
+ * Useful for ensuring functions receive non-empty input and for
130
+ * accumulating errors in Validation.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const errors: NonEmptyList<string> = ["First error", "Second error"];
135
+ *
136
+ * // TypeScript ensures at least one element:
137
+ * const invalid: NonEmptyList<string> = []; // Error!
138
+ * ```
139
+ */
140
+ type NonEmptyList<A> = readonly [A, ...A[]];
141
+ /**
142
+ * Type guard that checks if an array is non-empty.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * const items: string[] = getItems();
147
+ *
148
+ * if (isNonEmptyList(items)) {
149
+ * // TypeScript knows items has at least one element
150
+ * const first = items[0]; // string, not string | undefined
151
+ * }
152
+ * ```
153
+ */
154
+ declare const isNonEmptyList: <A>(list: readonly A[]) => list is NonEmptyList<A>;
155
+
156
156
  export { Brand, Duration, type NonEmptyList, isNonEmptyList };
package/dist/types.mjs CHANGED
@@ -1,11 +1,8 @@
1
- import "./chunk-IPP4XFYH.mjs";
2
- import {
3
- isNonEmptyList
4
- } from "./chunk-DBIC62UV.mjs";
5
1
  import {
6
2
  Brand,
7
- Duration
8
- } from "./chunk-VWVPHDZO.mjs";
3
+ Duration,
4
+ isNonEmptyList
5
+ } from "./chunk-5AFEEFE4.mjs";
9
6
  export {
10
7
  Brand,
11
8
  Duration,
package/dist/utils.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Task-fn1n--6H.mjs';
1
+ import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Task-DcXhCZYg.mjs';
2
2
  import { NonEmptyList } from './types.mjs';
3
3
 
4
4
  /**
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Task-DIgwvoIb.js';
1
+ import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Task-uupX7xd9.js';
2
2
  import { NonEmptyList } from './types.js';
3
3
 
4
4
  /**
package/dist/utils.js CHANGED
@@ -39,58 +39,6 @@ var Deferred;
39
39
  Deferred2.toPromise = (d) => new Promise((resolve) => d.then(resolve));
40
40
  })(Deferred || (Deferred = {}));
41
41
 
42
- // src/Core/Result.ts
43
- var Result;
44
- ((Result2) => {
45
- Result2.ok = (value) => ({ kind: "Ok", value });
46
- Result2.err = (e) => ({ kind: "Err", error: e });
47
- Result2.isOk = (data) => data.kind === "Ok";
48
- Result2.isErr = (data) => data.kind === "Err";
49
- Result2.tryCatch = (f, onError) => {
50
- try {
51
- return (0, Result2.ok)(f());
52
- } catch (error) {
53
- return (0, Result2.err)(onError(error));
54
- }
55
- };
56
- Result2.map = (f) => (data) => (0, Result2.isOk)(data) ? (0, Result2.ok)(f(data.value)) : data;
57
- Result2.mapError = (f) => (data) => (0, Result2.isErr)(data) ? (0, Result2.err)(f(data.error)) : data;
58
- Result2.chain = (f) => (data) => (0, Result2.isOk)(data) ? f(data.value) : data;
59
- Result2.fold = (onErr, onOk) => (data) => (0, Result2.isOk)(data) ? onOk(data.value) : onErr(data.error);
60
- Result2.match = (cases) => (data) => (0, Result2.isOk)(data) ? cases.ok(data.value) : cases.err(data.error);
61
- Result2.getOrElse = (defaultValue) => (data) => (0, Result2.isOk)(data) ? data.value : defaultValue();
62
- Result2.tap = (f) => (data) => {
63
- if ((0, Result2.isOk)(data)) {
64
- f(data.value);
65
- }
66
- return data;
67
- };
68
- Result2.tapError = (f) => (data) => {
69
- if ((0, Result2.isErr)(data)) {
70
- f(data.error);
71
- }
72
- return data;
73
- };
74
- Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
75
- Result2.fromNullable = (onNull) => (value) => value === null || value === void 0 ? (0, Result2.err)(onNull()) : (0, Result2.ok)(value);
76
- Result2.fromMaybe = (onNone) => (maybe) => Maybe.isNone(maybe) ? (0, Result2.err)(onNone()) : (0, Result2.ok)(maybe.value);
77
- Result2.fromThrowable = (f, onError) => (...args) => {
78
- try {
79
- return (0, Result2.ok)(f(...args));
80
- } catch (error) {
81
- return (0, Result2.err)(onError(error));
82
- }
83
- };
84
- Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
85
- Result2.recoverUnless = (isBlocked, fallback) => (data) => (0, Result2.isErr)(data) && !isBlocked(data.error) ? fallback() : data;
86
- Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
87
- Result2.ap = (arg) => (data) => (0, Result2.isOk)(data) && (0, Result2.isOk)(arg) ? (0, Result2.ok)(data.value(arg.value)) : (0, Result2.isErr)(data) ? data : arg;
88
- Result2.bindTo = (key) => (data) => (0, Result2.map)((a) => ({ [key]: a }))(data);
89
- Result2.bind = (key, f) => (data) => (0, Result2.chain)(
90
- (a) => (0, Result2.map)((b) => ({ ...a, [key]: b }))(f(a))
91
- )(data);
92
- })(Result || (Result = {}));
93
-
94
42
  // src/Core/Maybe.ts
95
43
  var _none = { kind: "None" };
96
44
  var Maybe;
@@ -123,6 +71,19 @@ var Maybe;
123
71
  Maybe2.bind = (key, f) => (data) => (0, Maybe2.chain)(
124
72
  (a) => (0, Maybe2.map)((b) => ({ ...a, [key]: b }))(f(a))
125
73
  )(data);
74
+ Maybe2.struct = (fields) => {
75
+ const result = {};
76
+ for (const key in fields) {
77
+ if (Object.hasOwn(fields, key)) {
78
+ const res = fields[key];
79
+ if ((0, Maybe2.isNone)(res)) {
80
+ return res;
81
+ }
82
+ result[key] = res.value;
83
+ }
84
+ }
85
+ return (0, Maybe2.some)(result);
86
+ };
126
87
  })(Maybe || (Maybe = {}));
127
88
 
128
89
  // src/Types/Brand.ts
@@ -150,6 +111,74 @@ var Duration;
150
111
  Duration2.subtract = (other) => (self) => wrap(Brand.unwrap(self) - Brand.unwrap(other));
151
112
  })(Duration || (Duration = {}));
152
113
 
114
+ // src/Types/NonEmptyList.ts
115
+ var isNonEmptyList = (list) => list.length > 0;
116
+
117
+ // src/Core/Result.ts
118
+ var Result;
119
+ ((Result2) => {
120
+ Result2.ok = (value) => ({ kind: "Ok", value });
121
+ Result2.err = (e) => ({ kind: "Err", error: e });
122
+ Result2.isOk = (data) => data.kind === "Ok";
123
+ Result2.isErr = (data) => data.kind === "Err";
124
+ Result2.tryCatch = (f, onError) => {
125
+ try {
126
+ return (0, Result2.ok)(f());
127
+ } catch (error) {
128
+ return (0, Result2.err)(onError(error));
129
+ }
130
+ };
131
+ Result2.map = (f) => (data) => (0, Result2.isOk)(data) ? (0, Result2.ok)(f(data.value)) : data;
132
+ Result2.mapError = (f) => (data) => (0, Result2.isErr)(data) ? (0, Result2.err)(f(data.error)) : data;
133
+ Result2.chain = (f) => (data) => (0, Result2.isOk)(data) ? f(data.value) : data;
134
+ Result2.fold = (onErr, onOk) => (data) => (0, Result2.isOk)(data) ? onOk(data.value) : onErr(data.error);
135
+ Result2.match = (cases) => (data) => (0, Result2.isOk)(data) ? cases.ok(data.value) : cases.err(data.error);
136
+ Result2.getOrElse = (defaultValue) => (data) => (0, Result2.isOk)(data) ? data.value : defaultValue();
137
+ Result2.tap = (f) => (data) => {
138
+ if ((0, Result2.isOk)(data)) {
139
+ f(data.value);
140
+ }
141
+ return data;
142
+ };
143
+ Result2.tapError = (f) => (data) => {
144
+ if ((0, Result2.isErr)(data)) {
145
+ f(data.error);
146
+ }
147
+ return data;
148
+ };
149
+ Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
150
+ Result2.fromNullable = (onNull) => (value) => value === null || value === void 0 ? (0, Result2.err)(onNull()) : (0, Result2.ok)(value);
151
+ Result2.fromMaybe = (onNone) => (maybe) => Maybe.isNone(maybe) ? (0, Result2.err)(onNone()) : (0, Result2.ok)(maybe.value);
152
+ Result2.fromThrowable = (f, onError) => (...args) => {
153
+ try {
154
+ return (0, Result2.ok)(f(...args));
155
+ } catch (error) {
156
+ return (0, Result2.err)(onError(error));
157
+ }
158
+ };
159
+ Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
160
+ Result2.recoverUnless = (isBlocked, fallback) => (data) => (0, Result2.isErr)(data) && !isBlocked(data.error) ? fallback() : data;
161
+ Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
162
+ Result2.ap = (arg) => (data) => (0, Result2.isOk)(data) && (0, Result2.isOk)(arg) ? (0, Result2.ok)(data.value(arg.value)) : (0, Result2.isErr)(data) ? data : arg;
163
+ Result2.bindTo = (key) => (data) => (0, Result2.map)((a) => ({ [key]: a }))(data);
164
+ Result2.bind = (key, f) => (data) => (0, Result2.chain)(
165
+ (a) => (0, Result2.map)((b) => ({ ...a, [key]: b }))(f(a))
166
+ )(data);
167
+ Result2.struct = (fields) => {
168
+ const result = {};
169
+ for (const key in fields) {
170
+ if (Object.hasOwn(fields, key)) {
171
+ const res = fields[key];
172
+ if ((0, Result2.isErr)(res)) {
173
+ return res;
174
+ }
175
+ result[key] = res.value;
176
+ }
177
+ }
178
+ return (0, Result2.ok)(result);
179
+ };
180
+ })(Result || (Result = {}));
181
+
153
182
  // src/Core/Task.ts
154
183
  var toPromise = (task, signal) => Deferred.toPromise(task(signal));
155
184
  var getMs = (duration) => Duration.toMilliseconds(duration);
@@ -378,9 +407,6 @@ var Task;
378
407
  )(data);
379
408
  })(Task || (Task = {}));
380
409
 
381
- // src/Types/NonEmptyList.ts
382
- var isNonEmptyList = (list) => list.length > 0;
383
-
384
410
  // src/Utils/Arr.ts
385
411
  var Arr;
386
412
  ((Arr2) => {
package/dist/utils.mjs CHANGED
@@ -5,10 +5,9 @@ import {
5
5
  Rec,
6
6
  Str,
7
7
  Uniq
8
- } from "./chunk-72BGUEQM.mjs";
9
- import "./chunk-PUMSVZB4.mjs";
10
- import "./chunk-DBIC62UV.mjs";
11
- import "./chunk-VWVPHDZO.mjs";
8
+ } from "./chunk-E7YI5PVW.mjs";
9
+ import "./chunk-M2X7TFKN.mjs";
10
+ import "./chunk-5AFEEFE4.mjs";
12
11
  export {
13
12
  Arr,
14
13
  Dict,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlozgachev/pipelined",
3
- "version": "0.37.0",
3
+ "version": "0.37.1",
4
4
  "description": "Opinionated functional abstractions for TypeScript",
5
5
  "license": "BSD-3-Clause",
6
6
  "homepage": "https://pipelined.lozgachev.dev",
@@ -23,6 +23,13 @@
23
23
  "files": [
24
24
  "dist"
25
25
  ],
26
+ "imports": {
27
+ "#core": "./src/Core/index.ts",
28
+ "#utils": "./src/Utils/index.ts",
29
+ "#types": "./src/Types/index.ts",
30
+ "#composition": "./src/Composition/index.ts",
31
+ "#internal": "./src/internal/index.ts"
32
+ },
26
33
  "exports": {
27
34
  "./composition": {
28
35
  "types": "./dist/composition.d.ts",
@@ -49,8 +56,8 @@
49
56
  "test": "vitest run",
50
57
  "bench": "vitest bench",
51
58
  "build": "tsup",
52
- "format": "dprint fmt && dprint fmt --config dprint.md.json docs/**/*.md docs/**/*.mdx README.md",
53
- "format:check": "dprint check && dprint check --config dprint.md.json docs/**/*.md docs/**/*.mdx README.md",
59
+ "format": "dprint fmt && dprint fmt --config dprint.md.json \"docs/**/*.md\" \"docs/**/*.mdx\" \"README.md\"",
60
+ "format:check": "dprint check && dprint check --config dprint.md.json \"docs/**/*.md\" \"docs/**/*.mdx\" \"README.md\"",
54
61
  "typecheck": "tsc --noEmit",
55
62
  "lint": "oxlint src/",
56
63
  "publish:npm": "pnpm build && npm publish --access public",
@@ -1,6 +0,0 @@
1
- // src/Types/NonEmptyList.ts
2
- var isNonEmptyList = (list) => list.length > 0;
3
-
4
- export {
5
- isNonEmptyList
6
- };
File without changes