@nlozgachev/pipelined 0.64.0 → 0.66.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/data.d.cts CHANGED
@@ -1,144 +1,148 @@
1
- import { a as NonEmptyArr, N as NonEmpty } from './InternalTypes-GFn4RTwD.cjs';
2
- import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Task-C_goFYQ1.cjs';
3
- import { B as Brand } from './Duration-DeyxG6VQ.cjs';
4
- import './types.cjs';
5
-
1
+ import { r as Brand } from "./index-Bs8En5LJ.cjs";
2
+ import { n as NonEmpty, r as NonEmptyArr } from "./InternalTypes-B1Lh9uw_.cjs";
3
+ import { C as Ordering, E as Maybe, N as Equality, a as Task, f as Result } from "./index-8A9NqJTq.cjs";
4
+ //#region src/Data/Arr.d.ts
6
5
  declare namespace ArrTaskResult {
7
- /**
8
- * Maps each element to a Task.Result and runs them sequentially.
9
- * Returns the first Err encountered, or Ok of all results if all succeed.
10
- *
11
- * @example
12
- * ```ts
13
- * const validate = (n: number): Task.Result<string, number> =>
14
- * n > 0 ? Task.Result.ok(n) : Task.Result.err("non-positive");
15
- *
16
- * pipe(
17
- * [1, 2, 3],
18
- * Arr.traverse.Task.Result(validate)
19
- * )(); // Deferred<Ok([1, 2, 3])>
20
- *
21
- * pipe(
22
- * [1, -1, 3],
23
- * Arr.traverse.Task.Result(validate)
24
- * )(); // Deferred<Err("non-positive")>
25
- * ```
26
- */
27
- const traverse: <E, A, B>(f: (a: A) => Task.Result<E, B>) => (data: readonly A[]) => Task.Result<E, readonly B[]>;
28
- /**
29
- * Collects an array of Task.Results into a Task.Result of array.
30
- * Returns the first Err if any element is Err, runs sequentially.
31
- *
32
- * @example
33
- * ```ts
34
- * pipe(
35
- * [Task.Result.ok(1), Task.Result.ok(2)],
36
- * Arr.sequence.Task.Result
37
- * )(); // Deferred<Ok([1, 2])>
38
- * ```
39
- */
40
- const sequence: <E, A>(data: readonly Task.Result<E, A>[]) => Task.Result<E, readonly A[]>;
6
+ /**
7
+ * Maps each element to a Task.Result and runs them sequentially.
8
+ * Returns the first Err encountered, or Ok of all results if all succeed.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const validate = (n: number): Task.Result<string, number> =>
13
+ * n > 0 ? Task.Result.ok(n) : Task.Result.err("non-positive");
14
+ *
15
+ * pipe(
16
+ * [1, 2, 3],
17
+ * Arr.traverse.Task.Result(validate)
18
+ * )(); // Deferred<Ok([1, 2, 3])>
19
+ *
20
+ * pipe(
21
+ * [1, -1, 3],
22
+ * Arr.traverse.Task.Result(validate)
23
+ * )(); // Deferred<Err("non-positive")>
24
+ * ```
25
+ */
26
+ const traverse: <E, A, B>(f: (a: A) => Task.Result<E, B>, options?: {
27
+ concurrency?: number;
28
+ }) => (data: readonly A[]) => Task.Result<E, readonly B[]>;
29
+ /**
30
+ * Collects an array of Task.Results into a Task.Result of array.
31
+ * Returns the first Err if any element is Err, runs sequentially.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * pipe(
36
+ * [Task.Result.ok(1), Task.Result.ok(2)],
37
+ * Arr.sequence.Task.Result
38
+ * )(); // Deferred<Ok([1, 2])>
39
+ * ```
40
+ */
41
+ const sequence: <E, A>(data: readonly Task.Result<E, A>[]) => Task.Result<E, readonly A[]>;
41
42
  }
42
43
  interface TaskTraverse {
43
- <A, B>(f: (a: A) => Task<B>): (data: readonly A[]) => Task<readonly B[]>;
44
- Result: typeof ArrTaskResult.traverse;
44
+ <A, B>(f: (a: A) => Task<B>, options?: {
45
+ concurrency?: number;
46
+ }): (data: readonly A[]) => Task<readonly B[]>;
47
+ Result: typeof ArrTaskResult.traverse;
45
48
  }
46
49
  interface TaskSequence {
47
- <A>(data: readonly Task<A>[]): Task<readonly A[]>;
48
- Result: typeof ArrTaskResult.sequence;
50
+ <A>(data: readonly Task<A>[]): Task<readonly A[]>;
51
+ Result: typeof ArrTaskResult.sequence;
49
52
  }
50
- declare const Arr: {
51
- head: <A>(data: readonly A[]) => Maybe<A>;
52
- last: <A>(data: readonly A[]) => Maybe<A>;
53
- tail: <A>(data: readonly A[]) => Maybe<readonly A[]>;
54
- init: <A>(data: readonly A[]) => Maybe<readonly A[]>;
55
- findFirst: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Maybe<A>;
56
- findLast: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Maybe<A>;
57
- findIndex: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Maybe<number>;
58
- map: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly B[];
59
- mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (data: readonly A[]) => readonly B[];
60
- filter: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
61
- filterMap: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => readonly B[];
62
- partition: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly [readonly A[], readonly A[]];
63
- compact: <A>(data: readonly Maybe<A>[]) => readonly A[];
64
- separate: <E, A>(data: readonly Result<E, A>[]) => readonly [readonly E[], readonly A[]];
65
- partitionMap: <A, E, B>(f: (a: A) => Result<E, B>) => (data: readonly A[]) => readonly [readonly E[], readonly B[]];
66
- groupBy: <A>(f: (a: A) => string) => (data: readonly A[]) => Record<string, NonEmptyArr<A>>;
67
- uniq: <A>(data: readonly A[]) => readonly A[];
68
- uniqBy: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly A[];
69
- uniqWith: <A>(eq: Equality<A>) => (data: readonly A[]) => readonly A[];
70
- sortBy: <A>(compare: (a: A, b: A) => number) => (data: readonly A[]) => readonly A[];
71
- sortWith: <A>(ord: Ordering<A>) => (data: readonly A[]) => readonly A[];
72
- zip: <B>(other: readonly B[]) => <A>(data: readonly A[]) => readonly (readonly [A, B])[];
73
- zipWith: <A, B, C>(f: (a: A, b: B) => C) => (other: readonly B[]) => (data: readonly A[]) => readonly C[];
74
- intersperse: <A>(sep: A) => (data: readonly A[]) => readonly A[];
75
- concat: <A>(other: readonly A[]) => (data: readonly A[]) => readonly A[];
76
- chunksOf: (n: number) => <A>(data: readonly A[]) => readonly (readonly A[])[];
77
- flatten: <A>(data: readonly (readonly A[])[]) => readonly A[];
78
- flatMap: <A, B>(f: (a: A) => readonly B[]) => (data: readonly A[]) => readonly B[];
79
- reduce: <A, B>(initial: B, f: (acc: B, a: A) => B) => (data: readonly A[]) => B;
80
- prepend: <A>(value: A) => (data: readonly A[]) => NonEmptyArr<A>;
81
- append: <A>(value: A) => (data: readonly A[]) => NonEmptyArr<A>;
82
- size: <A>(data: readonly A[]) => number;
83
- some: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => boolean;
84
- every: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => boolean;
85
- reverse: <A>(data: readonly A[]) => readonly A[];
86
- insertAt: <A>(index: number, item: A) => (data: readonly A[]) => readonly A[];
87
- removeAt: (index: number) => <A>(data: readonly A[]) => readonly A[];
88
- take: (n: number) => <A>(data: readonly A[]) => readonly A[];
89
- drop: (n: number) => <A>(data: readonly A[]) => readonly A[];
90
- takeWhile: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
91
- dropWhile: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
92
- scan: <A, B>(initial: B, f: (acc: B, a: A) => B) => (data: readonly A[]) => readonly B[];
93
- splitAt: (index: number) => <A>(data: readonly A[]) => readonly [readonly A[], readonly A[]];
94
- partitionMaybe: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => readonly [failures: readonly A[], successes: readonly B[]];
95
- at: (index: number) => <A>(data: readonly A[]) => Maybe<A>;
96
- findMap: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => Maybe<B>;
97
- indexBy: <A, K>(keyFn: (a: A) => K) => (data: readonly A[]) => ReadonlyMap<K, A>;
98
- frequencies: <A>(data: readonly A[]) => ReadonlyMap<A, number>;
99
- chunkBy: <A, K>(keyFn: (a: A) => K) => (data: readonly A[]) => readonly (readonly A[])[];
100
- dedupeAdjacent: <A>(eq?: Equality<A>) => (data: readonly A[]) => readonly A[];
101
- windowed: (windowSize: number, options?: {
102
- step?: number;
103
- }) => <A>(data: readonly A[]) => readonly (readonly A[])[];
104
- unfold: <A, S>(initial: S, f: (state: S) => Maybe<readonly [A, S]>) => readonly A[];
53
+ export declare const Arr: {
54
+ head: <A>(data: readonly A[]) => Maybe<A>;
55
+ last: <A>(data: readonly A[]) => Maybe<A>;
56
+ tail: <A>(data: readonly A[]) => Maybe<readonly A[]>;
57
+ init: <A>(data: readonly A[]) => Maybe<readonly A[]>;
58
+ findFirst: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Maybe<A>;
59
+ findLast: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Maybe<A>;
60
+ findIndex: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Maybe<number>;
61
+ map: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly B[];
62
+ mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (data: readonly A[]) => readonly B[];
63
+ filter: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
64
+ filterMap: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => readonly B[];
65
+ partition: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly [readonly A[], readonly A[]];
66
+ compact: <A>(data: readonly Maybe<A>[]) => readonly A[];
67
+ separate: <E, A>(data: readonly Result<E, A>[]) => readonly [readonly E[], readonly A[]];
68
+ partitionMap: <A, E, B>(f: (a: A) => Result<E, B>) => (data: readonly A[]) => readonly [readonly E[], readonly B[]];
69
+ groupBy: <A>(f: (a: A) => string) => (data: readonly A[]) => Record<string, NonEmptyArr<A>>;
70
+ uniq: <A>(data: readonly A[]) => readonly A[];
71
+ uniqBy: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly A[];
72
+ uniqWith: <A>(eq: Equality<A>) => (data: readonly A[]) => readonly A[];
73
+ sortBy: <A>(compare: (a: A, b: A) => number) => (data: readonly A[]) => readonly A[];
74
+ sortWith: <A>(ord: Ordering<A>) => (data: readonly A[]) => readonly A[];
75
+ zip: <B>(other: readonly B[]) => <A>(data: readonly A[]) => readonly (readonly [A, B])[];
76
+ zipWith: <A, B, C>(f: (a: A, b: B) => C) => (other: readonly B[]) => (data: readonly A[]) => readonly C[];
77
+ intersperse: <A>(sep: A) => (data: readonly A[]) => readonly A[];
78
+ concat: <A>(other: readonly A[]) => (data: readonly A[]) => readonly A[];
79
+ chunksOf: (n: number) => <A>(data: readonly A[]) => readonly (readonly A[])[];
80
+ flatten: <A>(data: readonly (readonly A[])[]) => readonly A[];
81
+ flatMap: <A, B>(f: (a: A) => readonly B[]) => (data: readonly A[]) => readonly B[];
82
+ reduce: <A, B>(initial: B, f: (acc: B, a: A) => B) => (data: readonly A[]) => B;
83
+ prepend: <A>(value: A) => (data: readonly A[]) => NonEmptyArr<A>;
84
+ append: <A>(value: A) => (data: readonly A[]) => NonEmptyArr<A>;
85
+ size: <A>(data: readonly A[]) => number;
86
+ some: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => boolean;
87
+ every: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => boolean;
88
+ reverse: <A>(data: readonly A[]) => readonly A[];
89
+ insertAt: <A>(index: number, item: A) => (data: readonly A[]) => readonly A[];
90
+ removeAt: (index: number) => <A>(data: readonly A[]) => readonly A[];
91
+ take: (n: number) => <A>(data: readonly A[]) => readonly A[];
92
+ drop: (n: number) => <A>(data: readonly A[]) => readonly A[];
93
+ takeWhile: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
94
+ dropWhile: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
95
+ scan: <A, B>(initial: B, f: (acc: B, a: A) => B) => (data: readonly A[]) => readonly B[];
96
+ splitAt: (index: number) => <A>(data: readonly A[]) => readonly [readonly A[], readonly A[]];
97
+ partitionMaybe: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => readonly [failures: readonly A[], successes: readonly B[]];
98
+ at: (index: number) => <A>(data: readonly A[]) => Maybe<A>;
99
+ findMap: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => Maybe<B>;
100
+ indexBy: <A, K>(keyFn: (a: A) => K) => (data: readonly A[]) => ReadonlyMap<K, A>;
101
+ frequencies: <A>(data: readonly A[]) => ReadonlyMap<A, number>;
102
+ chunkBy: <A, K>(keyFn: (a: A) => K) => (data: readonly A[]) => readonly (readonly A[])[];
103
+ dedupeAdjacent: <A>(eq?: Equality<A>) => (data: readonly A[]) => readonly A[];
104
+ windowed: (windowSize: number, options?: {
105
+ step?: number;
106
+ }) => <A>(data: readonly A[]) => readonly (readonly A[])[];
107
+ unfold: <A, S>(initial: S, f: (state: S) => Maybe<readonly [A, S]>) => readonly A[];
108
+ from: {
109
+ Array: <A>(data: readonly A[]) => Maybe<NonEmptyArr<A>>;
110
+ };
111
+ is: {
112
+ empty: <A>(data: readonly A[]) => data is readonly [];
113
+ nonEmpty: <A>(data: readonly A[]) => data is NonEmptyArr<A>;
114
+ };
115
+ traverse: {
116
+ Maybe: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => Maybe<readonly B[]>;
117
+ Result: <E, A, B>(f: (a: A) => Result<E, B>) => (data: readonly A[]) => Result<E, readonly B[]>;
118
+ Task: TaskTraverse;
119
+ };
120
+ sequence: {
121
+ Maybe: <A>(data: readonly Maybe<A>[]) => Maybe<readonly A[]>;
122
+ Result: <E, A>(data: readonly Result<E, A>[]) => Result<E, readonly A[]>;
123
+ Task: TaskSequence;
124
+ };
125
+ NonEmpty: {
126
+ singleton: <A>(value: A) => NonEmptyArr<A>;
105
127
  from: {
106
- Array: <A>(data: readonly A[]) => Maybe<NonEmptyArr<A>>;
107
- };
108
- is: {
109
- empty: <A>(data: readonly A[]) => data is readonly [];
110
- nonEmpty: <A>(data: readonly A[]) => data is NonEmptyArr<A>;
111
- };
112
- traverse: {
113
- Maybe: <A, B>(f: (a: A) => Maybe<B>) => (data: readonly A[]) => Maybe<readonly B[]>;
114
- Result: <E, A, B>(f: (a: A) => Result<E, B>) => (data: readonly A[]) => Result<E, readonly B[]>;
115
- Task: TaskTraverse;
116
- };
117
- sequence: {
118
- Maybe: <A>(data: readonly Maybe<A>[]) => Maybe<readonly A[]>;
119
- Result: <E, A>(data: readonly Result<E, A>[]) => Result<E, readonly A[]>;
120
- Task: TaskSequence;
121
- };
122
- NonEmpty: {
123
- singleton: <A>(value: A) => NonEmptyArr<A>;
124
- from: {
125
- Array: <A>(data: readonly A[]) => Maybe<NonEmptyArr<A>>;
126
- };
127
- head: <A>(data: NonEmptyArr<A>) => A;
128
- last: <A>(data: NonEmptyArr<A>) => A;
129
- tail: <A>(data: NonEmptyArr<A>) => readonly A[];
130
- reduce: <A>(f: (acc: A, a: A) => A) => (data: NonEmptyArr<A>) => A;
131
- map: <A, B>(f: (a: A) => B) => (data: NonEmptyArr<A>) => NonEmptyArr<B>;
132
- mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (data: NonEmptyArr<A>) => NonEmptyArr<B>;
133
- intersperse: <A>(sep: A) => (data: NonEmptyArr<A>) => NonEmptyArr<A>;
134
- concat: <A>(other: readonly A[]) => (data: NonEmptyArr<A>) => NonEmptyArr<A>;
135
- reverse: <A>(data: NonEmptyArr<A>) => NonEmptyArr<A>;
128
+ Array: <A>(data: readonly A[]) => Maybe<NonEmptyArr<A>>;
136
129
  };
130
+ head: <A>(data: NonEmptyArr<A>) => A;
131
+ last: <A>(data: NonEmptyArr<A>) => A;
132
+ tail: <A>(data: NonEmptyArr<A>) => readonly A[];
133
+ reduce: <A>(f: (acc: A, a: A) => A) => (data: NonEmptyArr<A>) => A;
134
+ map: <A, B>(f: (a: A) => B) => (data: NonEmptyArr<A>) => NonEmptyArr<B>;
135
+ mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (data: NonEmptyArr<A>) => NonEmptyArr<B>;
136
+ intersperse: <A>(sep: A) => (data: NonEmptyArr<A>) => NonEmptyArr<A>;
137
+ concat: <A>(other: readonly A[]) => (data: NonEmptyArr<A>) => NonEmptyArr<A>;
138
+ reverse: <A>(data: NonEmptyArr<A>) => NonEmptyArr<A>;
139
+ };
137
140
  };
138
- declare namespace Arr {
139
- type NonEmpty<A> = NonEmptyArr<A>;
141
+ export declare namespace Arr {
142
+ type NonEmpty<A> = NonEmptyArr<A>;
140
143
  }
141
-
144
+ //#endregion
145
+ //#region src/Data/BigNum.d.ts
142
146
  /**
143
147
  * Safe conversion and arithmetic utilities for arbitrary-precision integers (`bigint`).
144
148
  * All functions are pure and data-last to compose cleanly with `pipe`.
@@ -154,544 +158,547 @@ declare namespace Arr {
154
158
  * ); // Some(150n)
155
159
  * ```
156
160
  */
157
- declare const BigNum: {
158
- is: {
159
- /**
160
- * Returns `true` when the bigint is equal to zero (`0n`).
161
- *
162
- * @example
163
- * ```ts
164
- * BigNum.is.zero(0n); // true
165
- * BigNum.is.zero(5n); // false
166
- * ```
167
- */
168
- zero: (b: bigint) => boolean;
169
- /**
170
- * Returns `true` when the bigint is an even integer.
171
- *
172
- * @example
173
- * ```ts
174
- * BigNum.is.even(4n); // true
175
- * BigNum.is.even(3n); // false
176
- * ```
177
- */
178
- even: (b: bigint) => boolean;
179
- /**
180
- * Returns `true` when the bigint is an odd integer.
181
- *
182
- * @example
183
- * ```ts
184
- * BigNum.is.odd(3n); // true
185
- * BigNum.is.odd(4n); // false
186
- * ```
187
- */
188
- odd: (b: bigint) => boolean;
189
- /**
190
- * Returns `true` when the bigint is strictly greater than zero (`0n`).
191
- *
192
- * @example
193
- * ```ts
194
- * BigNum.is.positive(5n); // true
195
- * BigNum.is.positive(0n); // false
196
- * BigNum.is.positive(-5n); // false
197
- * ```
198
- */
199
- positive: (b: bigint) => boolean;
200
- /**
201
- * Returns `true` when the bigint is strictly less than zero (`0n`).
202
- *
203
- * @example
204
- * ```ts
205
- * BigNum.is.negative(-5n); // true
206
- * BigNum.is.negative(0n); // false
207
- * BigNum.is.negative(5n); // false
208
- * ```
209
- */
210
- negative: (b: bigint) => boolean;
211
- };
212
- from: {
213
- /**
214
- * Safely parses a string into a `bigint`. Returns `None` if parsing fails.
215
- *
216
- * @example
217
- * ```ts
218
- * BigNum.from.string("123"); // Some(123n)
219
- * BigNum.from.string("abc"); // None
220
- * ```
221
- */
222
- string: (s: string) => Maybe<bigint>;
223
- /**
224
- * Safely converts a number into a `bigint`. Returns `None` for floats, `NaN`, or non-safe integers.
225
- *
226
- * @example
227
- * ```ts
228
- * BigNum.from.number(42); // Some(42n)
229
- * BigNum.from.number(3.14); // None
230
- * ```
231
- */
232
- number: (n: number) => Maybe<bigint>;
233
- };
234
- to: {
235
- /**
236
- * Safely converts a `bigint` to a `number`. Returns `None` if the value is outside JavaScript's safe integer range.
237
- *
238
- * @example
239
- * ```ts
240
- * BigNum.to.number(42n); // Some(42)
241
- * BigNum.to.number(9007199254740993n); // None
242
- * ```
243
- */
244
- number: (b: bigint) => Maybe<number>;
245
- };
246
- /**
247
- * Adds `b` to `a`. Data-last curried signature: `add(b)(a)` = `a + b`.
248
- *
249
- * @example
250
- * ```ts
251
- * pipe(10n, BigNum.add(5n)); // 15n
252
- * ```
253
- */
254
- add: (b: bigint) => (a: bigint) => bigint;
255
- /**
256
- * Subtracts `b` from `a`. Data-last curried signature: `sub(b)(a)` = `a - b`.
257
- *
258
- * @example
259
- * ```ts
260
- * pipe(10n, BigNum.sub(3n)); // 7n
261
- * ```
262
- */
263
- sub: (b: bigint) => (a: bigint) => bigint;
161
+ export declare const BigNum: {
162
+ is: {
264
163
  /**
265
- * Multiplies `a` by `b`. Data-last curried signature: `mul(b)(a)` = `a * b`.
164
+ * Returns `true` when the bigint is equal to zero (`0n`).
266
165
  *
267
166
  * @example
268
167
  * ```ts
269
- * pipe(6n, BigNum.mul(7n)); // 42n
168
+ * BigNum.is.zero(0n); // true
169
+ * BigNum.is.zero(5n); // false
270
170
  * ```
271
171
  */
272
- mul: (b: bigint) => (a: bigint) => bigint;
172
+ zero: (b: bigint) => boolean;
273
173
  /**
274
- * Divides `a` by `b`. Returns `None` if `b` is `0n`.
174
+ * Returns `true` when the bigint is an even integer.
275
175
  *
276
176
  * @example
277
177
  * ```ts
278
- * pipe(20n, BigNum.div(4n)); // Some(5n)
279
- * pipe(5n, BigNum.div(0n)); // None
178
+ * BigNum.is.even(4n); // true
179
+ * BigNum.is.even(3n); // false
280
180
  * ```
281
181
  */
282
- div: (b: bigint) => (a: bigint) => Maybe<bigint>;
182
+ even: (b: bigint) => boolean;
283
183
  /**
284
- * Computes remainder of `a / b`. Returns `None` if `b` is `0n`.
184
+ * Returns `true` when the bigint is an odd integer.
285
185
  *
286
186
  * @example
287
187
  * ```ts
288
- * pipe(10n, BigNum.mod(3n)); // Some(1n)
289
- * pipe(5n, BigNum.mod(0n)); // None
188
+ * BigNum.is.odd(3n); // true
189
+ * BigNum.is.odd(4n); // false
290
190
  * ```
291
191
  */
292
- mod: (b: bigint) => (a: bigint) => Maybe<bigint>;
192
+ odd: (b: bigint) => boolean;
293
193
  /**
294
- * Clamps `a` between `min` and `max` (inclusive).
194
+ * Returns `true` when the bigint is strictly greater than zero (`0n`).
295
195
  *
296
196
  * @example
297
197
  * ```ts
298
- * pipe(150n, BigNum.clamp(0n, 100n)); // 100n
198
+ * BigNum.is.positive(5n); // true
199
+ * BigNum.is.positive(0n); // false
200
+ * BigNum.is.positive(-5n); // false
299
201
  * ```
300
202
  */
301
- clamp: (min: bigint, max: bigint) => (a: bigint) => bigint;
203
+ positive: (b: bigint) => boolean;
302
204
  /**
303
- * Returns `true` if `a` is in the range `[start, end)` (inclusive start, exclusive end).
205
+ * Returns `true` when the bigint is strictly less than zero (`0n`).
304
206
  *
305
207
  * @example
306
208
  * ```ts
307
- * pipe(5n, BigNum.inRange(1n, 10n)); // true
209
+ * BigNum.is.negative(-5n); // true
210
+ * BigNum.is.negative(0n); // false
211
+ * BigNum.is.negative(5n); // false
308
212
  * ```
309
213
  */
310
- inRange: (start: bigint, end: bigint) => (a: bigint) => boolean;
214
+ negative: (b: bigint) => boolean;
215
+ };
216
+ from: {
311
217
  /**
312
- * Returns absolute value of a `bigint`.
218
+ * Safely parses a string into a `bigint`. Returns `None` if parsing fails.
313
219
  *
314
220
  * @example
315
221
  * ```ts
316
- * BigNum.abs(-42n); // 42n
222
+ * BigNum.from.string("123"); // Some(123n)
223
+ * BigNum.from.string("abc"); // None
317
224
  * ```
318
225
  */
319
- abs: (a: bigint) => bigint;
226
+ string: (s: string) => Maybe<bigint>;
320
227
  /**
321
- * Returns the minimum of `a` and `b`.
228
+ * Safely converts a number into a `bigint`. Returns `None` for floats, `NaN`, or non-safe integers.
322
229
  *
323
230
  * @example
324
231
  * ```ts
325
- * pipe(10n, BigNum.min(5n)); // 5n
232
+ * BigNum.from.number(42); // Some(42n)
233
+ * BigNum.from.number(3.14); // None
326
234
  * ```
327
235
  */
328
- min: (b: bigint) => (a: bigint) => bigint;
236
+ number: (n: number) => Maybe<bigint>;
237
+ };
238
+ to: {
329
239
  /**
330
- * Returns the maximum of `a` and `b`.
240
+ * Safely converts a `bigint` to a `number`. Returns `None` if the value is outside JavaScript's safe integer range.
331
241
  *
332
242
  * @example
333
243
  * ```ts
334
- * pipe(10n, BigNum.max(5n)); // 10n
244
+ * BigNum.to.number(42n); // Some(42)
245
+ * BigNum.to.number(9007199254740993n); // None
335
246
  * ```
336
247
  */
337
- max: (b: bigint) => (a: bigint) => bigint;
248
+ number: (b: bigint) => Maybe<number>;
249
+ };
250
+ /**
251
+ * Adds `b` to `a`. Data-last curried signature: `add(b)(a)` = `a + b`.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * pipe(10n, BigNum.add(5n)); // 15n
256
+ * ```
257
+ */
258
+ add: (b: bigint) => (a: bigint) => bigint;
259
+ /**
260
+ * Subtracts `b` from `a`. Data-last curried signature: `sub(b)(a)` = `a - b`.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * pipe(10n, BigNum.sub(3n)); // 7n
265
+ * ```
266
+ */
267
+ sub: (b: bigint) => (a: bigint) => bigint;
268
+ /**
269
+ * Multiplies `a` by `b`. Data-last curried signature: `mul(b)(a)` = `a * b`.
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * pipe(6n, BigNum.mul(7n)); // 42n
274
+ * ```
275
+ */
276
+ mul: (b: bigint) => (a: bigint) => bigint;
277
+ /**
278
+ * Divides `a` by `b`. Returns `None` if `b` is `0n`.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * pipe(20n, BigNum.div(4n)); // Some(5n)
283
+ * pipe(5n, BigNum.div(0n)); // None
284
+ * ```
285
+ */
286
+ div: (b: bigint) => (a: bigint) => Maybe<bigint>;
287
+ /**
288
+ * Computes remainder of `a / b`. Returns `None` if `b` is `0n`.
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * pipe(10n, BigNum.mod(3n)); // Some(1n)
293
+ * pipe(5n, BigNum.mod(0n)); // None
294
+ * ```
295
+ */
296
+ mod: (b: bigint) => (a: bigint) => Maybe<bigint>;
297
+ /**
298
+ * Clamps `a` between `min` and `max` (inclusive).
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * pipe(150n, BigNum.clamp(0n, 100n)); // 100n
303
+ * ```
304
+ */
305
+ clamp: (min: bigint, max: bigint) => (a: bigint) => bigint;
306
+ /**
307
+ * Returns `true` if `a` is in the range `[start, end)` (inclusive start, exclusive end).
308
+ *
309
+ * @example
310
+ * ```ts
311
+ * pipe(5n, BigNum.inRange(1n, 10n)); // true
312
+ * ```
313
+ */
314
+ inRange: (start: bigint, end: bigint) => (a: bigint) => boolean;
315
+ /**
316
+ * Returns absolute value of a `bigint`.
317
+ *
318
+ * @example
319
+ * ```ts
320
+ * BigNum.abs(-42n); // 42n
321
+ * ```
322
+ */
323
+ abs: (a: bigint) => bigint;
324
+ /**
325
+ * Returns the minimum of `a` and `b`.
326
+ *
327
+ * @example
328
+ * ```ts
329
+ * pipe(10n, BigNum.min(5n)); // 5n
330
+ * ```
331
+ */
332
+ min: (b: bigint) => (a: bigint) => bigint;
333
+ /**
334
+ * Returns the maximum of `a` and `b`.
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * pipe(10n, BigNum.max(5n)); // 10n
339
+ * ```
340
+ */
341
+ max: (b: bigint) => (a: bigint) => bigint;
338
342
  };
339
-
340
- type BoolMatchCases<A, B> = {
341
- readonly true: () => A;
342
- readonly false: () => B;
343
+ //#endregion
344
+ //#region src/Data/Bool.d.ts
345
+ export type BoolMatchCases<A, B> = {
346
+ readonly true: () => A;
347
+ readonly false: () => B;
343
348
  };
344
- declare const Bool: {
345
- is: {
346
- /**
347
- * Type guard — checks if a value is a primitive boolean.
348
- *
349
- * @example
350
- * ```ts
351
- * Bool.is.boolean(true); // true
352
- * Bool.is.boolean(false); // true
353
- * Bool.is.boolean("true"); // false
354
- * Bool.is.boolean(null); // false
355
- * ```
356
- */
357
- boolean: (u: unknown) => u is boolean;
358
- /**
359
- * Narrowing guard — checks if a value is strictly `true`.
360
- *
361
- * @example
362
- * ```ts
363
- * Bool.is.true(true); // true
364
- * Bool.is.true(false); // false
365
- * ```
366
- */
367
- true: (u: unknown) => u is true;
368
- /**
369
- * Narrowing guard — checks if a value is strictly `false`.
370
- *
371
- * @example
372
- * ```ts
373
- * Bool.is.false(false); // true
374
- * Bool.is.false(true); // false
375
- * ```
376
- */
377
- false: (u: unknown) => u is false;
378
- /**
379
- * Type guard — checks if a value is truthy (not `false`, `0`, `0n`, `""`, `null`, `undefined`, or `NaN`).
380
- *
381
- * @example
382
- * ```ts
383
- * Bool.is.truthy("hello"); // true
384
- * Bool.is.truthy(42); // true
385
- * Bool.is.truthy(0); // false
386
- * Bool.is.truthy(null); // false
387
- * ```
388
- */
389
- truthy: <T>(u: T) => u is Exclude<T, false | 0 | 0n | "" | null | undefined>;
390
- /**
391
- * Type guard — checks if a value is falsy (`false`, `0`, `0n`, `""`, `null`, `undefined`, or `NaN`).
392
- *
393
- * @example
394
- * ```ts
395
- * Bool.is.falsy(""); // true
396
- * Bool.is.falsy(null); // true
397
- * Bool.is.falsy("content"); // false
398
- * ```
399
- */
400
- falsy: (u: unknown) => u is false | 0 | 0n | "" | null | undefined;
401
- };
402
- /**
403
- * Unary boolean negation: inverts the given boolean value.
404
- *
405
- * @example
406
- * ```ts
407
- * Bool.not(true); // false
408
- * Bool.not(false); // true
409
- * ```
410
- */
411
- not: (b: boolean) => boolean;
349
+ export declare const Bool: {
350
+ is: {
412
351
  /**
413
- * Logical AND combinator. Returns `true` only if both `self` and `that` are `true`.
414
- *
415
- * Data-last: `pipe(self, Bool.and(that))`.
352
+ * Type guard — checks if a value is a primitive boolean.
416
353
  *
417
354
  * @example
418
355
  * ```ts
419
- * pipe(true, Bool.and(true)); // true
420
- * pipe(true, Bool.and(false)); // false
356
+ * Bool.is.boolean(true); // true
357
+ * Bool.is.boolean(false); // true
358
+ * Bool.is.boolean("true"); // false
359
+ * Bool.is.boolean(null); // false
421
360
  * ```
422
361
  */
423
- and: (that: boolean) => (self: boolean) => boolean;
362
+ boolean: (u: unknown) => u is boolean;
424
363
  /**
425
- * Logical OR combinator. Returns `true` if either `self` or `that` is `true`.
426
- *
427
- * Data-last: `pipe(self, Bool.or(that))`.
364
+ * Narrowing guard — checks if a value is strictly `true`.
428
365
  *
429
366
  * @example
430
367
  * ```ts
431
- * pipe(false, Bool.or(true)); // true
432
- * pipe(false, Bool.or(false)); // false
368
+ * Bool.is.true(true); // true
369
+ * Bool.is.true(false); // false
433
370
  * ```
434
371
  */
435
- or: (that: boolean) => (self: boolean) => boolean;
436
- /**
437
- * Logical XOR (exclusive OR) combinator. Returns `true` if exactly one of `self` and `that` is `true`.
438
- *
439
- * Data-last: `pipe(self, Bool.xor(that))`.
440
- *
441
- * @example
442
- * ```ts
443
- * pipe(true, Bool.xor(false)); // true
444
- * pipe(true, Bool.xor(true)); // false
445
- * ```
446
- */
447
- xor: (that: boolean) => (self: boolean) => boolean;
448
- /**
449
- * Lazy logical AND combinator.
450
- * If `self` is `false`, the `that` computation is never evaluated.
451
- *
452
- * Data-last: `pipe(self, Bool.andLazy(that))`.
372
+ true: (u: unknown) => u is true;
373
+ /**
374
+ * Narrowing guard — checks if a value is strictly `false`.
375
+ *
376
+ * @example
377
+ * ```ts
378
+ * Bool.is.false(false); // true
379
+ * Bool.is.false(true); // false
380
+ * ```
381
+ */
382
+ false: (u: unknown) => u is false;
383
+ /**
384
+ * Type guard — checks if a value is truthy (not `false`, `0`, `0n`, `""`, `null`, `undefined`, or `NaN`).
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * Bool.is.truthy("hello"); // true
389
+ * Bool.is.truthy(42); // true
390
+ * Bool.is.truthy(0); // false
391
+ * Bool.is.truthy(null); // false
392
+ * ```
393
+ */
394
+ truthy: <T>(u: T) => u is Exclude<T, false | 0 | 0n | "" | null | undefined>;
395
+ /**
396
+ * Type guard — checks if a value is falsy (`false`, `0`, `0n`, `""`, `null`, `undefined`, or `NaN`).
397
+ *
398
+ * @example
399
+ * ```ts
400
+ * Bool.is.falsy(""); // true
401
+ * Bool.is.falsy(null); // true
402
+ * Bool.is.falsy("content"); // false
403
+ * ```
404
+ */
405
+ falsy: (u: unknown) => u is false | 0 | 0n | "" | null | undefined;
406
+ };
407
+ /**
408
+ * Unary boolean negation: inverts the given boolean value.
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * Bool.not(true); // false
413
+ * Bool.not(false); // true
414
+ * ```
415
+ */
416
+ not: (b: boolean) => boolean;
417
+ /**
418
+ * Logical AND combinator. Returns `true` only if both `self` and `that` are `true`.
419
+ *
420
+ * Data-last: `pipe(self, Bool.and(that))`.
421
+ *
422
+ * @example
423
+ * ```ts
424
+ * pipe(true, Bool.and(true)); // true
425
+ * pipe(true, Bool.and(false)); // false
426
+ * ```
427
+ */
428
+ and: (that: boolean) => (self: boolean) => boolean;
429
+ /**
430
+ * Logical OR combinator. Returns `true` if either `self` or `that` is `true`.
431
+ *
432
+ * Data-last: `pipe(self, Bool.or(that))`.
433
+ *
434
+ * @example
435
+ * ```ts
436
+ * pipe(false, Bool.or(true)); // true
437
+ * pipe(false, Bool.or(false)); // false
438
+ * ```
439
+ */
440
+ or: (that: boolean) => (self: boolean) => boolean;
441
+ /**
442
+ * Logical XOR (exclusive OR) combinator. Returns `true` if exactly one of `self` and `that` is `true`.
443
+ *
444
+ * Data-last: `pipe(self, Bool.xor(that))`.
445
+ *
446
+ * @example
447
+ * ```ts
448
+ * pipe(true, Bool.xor(false)); // true
449
+ * pipe(true, Bool.xor(true)); // false
450
+ * ```
451
+ */
452
+ xor: (that: boolean) => (self: boolean) => boolean;
453
+ /**
454
+ * Lazy logical AND combinator.
455
+ * If `self` is `false`, the `that` computation is never evaluated.
456
+ *
457
+ * Data-last: `pipe(self, Bool.andLazy(that))`.
458
+ *
459
+ * @example
460
+ * ```ts
461
+ * pipe(
462
+ * isCached,
463
+ * Bool.andLazy(() => checkPermissions())
464
+ * );
465
+ * ```
466
+ */
467
+ andLazy: (that: () => boolean) => (self: boolean) => boolean;
468
+ /**
469
+ * Lazy logical OR combinator.
470
+ * If `self` is `true`, the `that` computation is never evaluated.
471
+ *
472
+ * Data-last: `pipe(self, Bool.orLazy(that))`.
473
+ *
474
+ * @example
475
+ * ```ts
476
+ * pipe(
477
+ * isAdmin,
478
+ * Bool.orLazy(() => hasAccess(userId))
479
+ * );
480
+ * ```
481
+ */
482
+ orLazy: (that: () => boolean) => (self: boolean) => boolean;
483
+ /**
484
+ * N-ary AND aggregation across an array of booleans.
485
+ * Returns `true` if every boolean is `true`, or for an empty array (vacuous truth).
486
+ * Short-circuits on the first `false`.
487
+ *
488
+ * @example
489
+ * ```ts
490
+ * Bool.all([true, true, true]); // true
491
+ * Bool.all([true, false, true]); // false
492
+ * Bool.all([]); // true
493
+ * ```
494
+ */
495
+ all: (booleans: readonly boolean[]) => boolean;
496
+ /**
497
+ * N-ary OR aggregation across an array of booleans.
498
+ * Returns `true` if at least one boolean is `true`. Returns `false` for an empty array.
499
+ * Short-circuits on the first `true`.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * Bool.any([false, true, false]); // true
504
+ * Bool.any([false, false]); // false
505
+ * Bool.any([]); // false
506
+ * ```
507
+ */
508
+ any: (booleans: readonly boolean[]) => boolean;
509
+ /**
510
+ * Catamorphism for boolean: evaluates `onFalse()` when `false` and `onTrue()` when `true`.
511
+ *
512
+ * Positional ordering: `onFalse` first, `onTrue` second.
513
+ * Aligned with `Result.fold(onErr, onOk)` and `Maybe.fold(onNone, onSome)`.
514
+ *
515
+ * @example
516
+ * ```ts
517
+ * pipe(
518
+ * isDarkMode,
519
+ * Bool.fold(
520
+ * () => "light-theme",
521
+ * () => "dark-theme"
522
+ * )
523
+ * );
524
+ * ```
525
+ */
526
+ fold: <A, B>(onFalse: () => A, onTrue: () => B) => (b: boolean) => A | B;
527
+ /**
528
+ * Pattern matching on boolean using named cases `{ true, false }`.
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * pipe(
533
+ * isEnabled,
534
+ * Bool.match({
535
+ * true: () => "Feature Active",
536
+ * false: () => "Feature Disabled",
537
+ * })
538
+ * );
539
+ * ```
540
+ */
541
+ match: <A, B>(cases: BoolMatchCases<A, B>) => (b: boolean) => A | B;
542
+ from: {
543
+ /**
544
+ * Parses a string into a `Maybe<boolean>`.
545
+ * Returns `Some(true)` for `"true"`, `Some(false)` for `"false"` (case-insensitive & trimmed),
546
+ * and `None` for any other string.
547
+ *
548
+ * @example
549
+ * ```ts
550
+ * Bool.from.string("true"); // Some(true)
551
+ * Bool.from.string("FALSE"); // Some(false)
552
+ * Bool.from.string("yes"); // None
553
+ * ```
554
+ */
555
+ string: (s: string) => Maybe<boolean>;
556
+ /**
557
+ * Converts a number into a `Maybe<boolean>`.
558
+ * Returns `Some(true)` for `1`, `Some(false)` for `0`, and `None` for any other number.
559
+ *
560
+ * @example
561
+ * ```ts
562
+ * Bool.from.number(1); // Some(true)
563
+ * Bool.from.number(0); // Some(false)
564
+ * Bool.from.number(42); // None
565
+ * ```
566
+ */
567
+ number: (n: number) => Maybe<boolean>;
568
+ /**
569
+ * Coerces any unknown value into a boolean via standard JS `Boolean(value)`.
570
+ *
571
+ * @example
572
+ * ```ts
573
+ * Bool.from.truthy("hello"); // true
574
+ * Bool.from.truthy(0); // false
575
+ * ```
576
+ */
577
+ truthy: (value: unknown) => boolean;
578
+ };
579
+ to: {
580
+ /**
581
+ * Lifts a boolean condition into a `Maybe`.
582
+ * Returns `Some(onTrue())` when `true`, and `None` when `false`.
453
583
  *
454
584
  * @example
455
585
  * ```ts
456
586
  * pipe(
457
- * isCached,
458
- * Bool.andLazy(() => checkPermissions())
459
- * );
587
+ * user.isVerified,
588
+ * Bool.to.Maybe(() => user.profile)
589
+ * ); // Some(profile) or None
460
590
  * ```
461
591
  */
462
- andLazy: (that: () => boolean) => (self: boolean) => boolean;
592
+ Maybe: <A>(onTrue: () => A) => (b: boolean) => Maybe<A>;
463
593
  /**
464
- * Lazy logical OR combinator.
465
- * If `self` is `true`, the `that` computation is never evaluated.
466
- *
467
- * Data-last: `pipe(self, Bool.orLazy(that))`.
594
+ * Lifts a boolean condition into a `Result`.
595
+ * Returns `Ok(onOk())` when `true`, and `Err(onErr())` when `false`.
468
596
  *
469
597
  * @example
470
598
  * ```ts
471
599
  * pipe(
472
- * isAdmin,
473
- * Bool.orLazy(() => hasAccess(userId))
474
- * );
475
- * ```
476
- */
477
- orLazy: (that: () => boolean) => (self: boolean) => boolean;
478
- /**
479
- * N-ary AND aggregation across an array of booleans.
480
- * Returns `true` if every boolean is `true`, or for an empty array (vacuous truth).
481
- * Short-circuits on the first `false`.
482
- *
483
- * @example
484
- * ```ts
485
- * Bool.all([true, true, true]); // true
486
- * Bool.all([true, false, true]); // false
487
- * Bool.all([]); // true
488
- * ```
489
- */
490
- all: (booleans: readonly boolean[]) => boolean;
491
- /**
492
- * N-ary OR aggregation across an array of booleans.
493
- * Returns `true` if at least one boolean is `true`. Returns `false` for an empty array.
494
- * Short-circuits on the first `true`.
495
- *
496
- * @example
497
- * ```ts
498
- * Bool.any([false, true, false]); // true
499
- * Bool.any([false, false]); // false
500
- * Bool.any([]); // false
600
+ * hasPermission,
601
+ * Bool.to.Result(
602
+ * () => "Permission denied",
603
+ * () => sessionData
604
+ * )
605
+ * ); // Ok(sessionData) or Err("Permission denied")
501
606
  * ```
502
607
  */
503
- any: (booleans: readonly boolean[]) => boolean;
608
+ Result: <E, A>(onErr: () => E, onOk: () => A) => (b: boolean) => Result<E, A>;
504
609
  /**
505
- * Catamorphism for boolean: evaluates `onFalse()` when `false` and `onTrue()` when `true`.
506
- *
507
- * Positional ordering: `onFalse` first, `onTrue` second.
508
- * Aligned with `Result.fold(onErr, onOk)` and `Maybe.fold(onNone, onSome)`.
610
+ * Converts a boolean to numeric `1` or `0`.
509
611
  *
510
612
  * @example
511
613
  * ```ts
512
- * pipe(
513
- * isDarkMode,
514
- * Bool.fold(
515
- * () => "light-theme",
516
- * () => "dark-theme"
517
- * )
518
- * );
614
+ * Bool.to.number(true); // 1
615
+ * Bool.to.number(false); // 0
519
616
  * ```
520
617
  */
521
- fold: <A, B>(onFalse: () => A, onTrue: () => B) => (b: boolean) => A | B;
618
+ number: (b: boolean) => 1 | 0;
522
619
  /**
523
- * Pattern matching on boolean using named cases `{ true, false }`.
620
+ * Converts a boolean to literal string `"true"` or `"false"`.
524
621
  *
525
622
  * @example
526
623
  * ```ts
527
- * pipe(
528
- * isEnabled,
529
- * Bool.match({
530
- * true: () => "Feature Active",
531
- * false: () => "Feature Disabled",
532
- * })
533
- * );
624
+ * Bool.to.string(true); // "true"
625
+ * Bool.to.string(false); // "false"
534
626
  * ```
535
627
  */
536
- match: <A, B>(cases: BoolMatchCases<A, B>) => (b: boolean) => A | B;
537
- from: {
538
- /**
539
- * Parses a string into a `Maybe<boolean>`.
540
- * Returns `Some(true)` for `"true"`, `Some(false)` for `"false"` (case-insensitive & trimmed),
541
- * and `None` for any other string.
542
- *
543
- * @example
544
- * ```ts
545
- * Bool.from.string("true"); // Some(true)
546
- * Bool.from.string("FALSE"); // Some(false)
547
- * Bool.from.string("yes"); // None
548
- * ```
549
- */
550
- string: (s: string) => Maybe<boolean>;
551
- /**
552
- * Converts a number into a `Maybe<boolean>`.
553
- * Returns `Some(true)` for `1`, `Some(false)` for `0`, and `None` for any other number.
554
- *
555
- * @example
556
- * ```ts
557
- * Bool.from.number(1); // Some(true)
558
- * Bool.from.number(0); // Some(false)
559
- * Bool.from.number(42); // None
560
- * ```
561
- */
562
- number: (n: number) => Maybe<boolean>;
563
- /**
564
- * Coerces any unknown value into a boolean via standard JS `Boolean(value)`.
565
- *
566
- * @example
567
- * ```ts
568
- * Bool.from.truthy("hello"); // true
569
- * Bool.from.truthy(0); // false
570
- * ```
571
- */
572
- truthy: (value: unknown) => boolean;
573
- };
574
- to: {
575
- /**
576
- * Lifts a boolean condition into a `Maybe`.
577
- * Returns `Some(onTrue())` when `true`, and `None` when `false`.
578
- *
579
- * @example
580
- * ```ts
581
- * pipe(
582
- * user.isVerified,
583
- * Bool.to.Maybe(() => user.profile)
584
- * ); // Some(profile) or None
585
- * ```
586
- */
587
- Maybe: <A>(onTrue: () => A) => (b: boolean) => Maybe<A>;
588
- /**
589
- * Lifts a boolean condition into a `Result`.
590
- * Returns `Ok(onOk())` when `true`, and `Err(onErr())` when `false`.
591
- *
592
- * @example
593
- * ```ts
594
- * pipe(
595
- * hasPermission,
596
- * Bool.to.Result(
597
- * () => "Permission denied",
598
- * () => sessionData
599
- * )
600
- * ); // Ok(sessionData) or Err("Permission denied")
601
- * ```
602
- */
603
- Result: <E, A>(onErr: () => E, onOk: () => A) => (b: boolean) => Result<E, A>;
604
- /**
605
- * Converts a boolean to numeric `1` or `0`.
606
- *
607
- * @example
608
- * ```ts
609
- * Bool.to.number(true); // 1
610
- * Bool.to.number(false); // 0
611
- * ```
612
- */
613
- number: (b: boolean) => 1 | 0;
614
- /**
615
- * Converts a boolean to literal string `"true"` or `"false"`.
616
- *
617
- * @example
618
- * ```ts
619
- * Bool.to.string(true); // "true"
620
- * Bool.to.string(false); // "false"
621
- * ```
622
- */
623
- string: (b: boolean) => "true" | "false";
624
- };
628
+ string: (b: boolean) => "true" | "false";
629
+ };
625
630
  };
626
-
631
+ //#endregion
632
+ //#region src/Data/Dict.d.ts
627
633
  /**
628
634
  * A branded type representing a key-value dictionary with at least one entry.
629
635
  */
630
- type NonEmptyMap<K, V> = Brand<NonEmpty<"Dict">, ReadonlyMap<K, V>>;
636
+ export type NonEmptyMap<K, V> = Brand<NonEmpty<"Dict">, ReadonlyMap<K, V>>;
631
637
  declare function mergeWith$1<V>(combine: (a: V, b: V) => V): {
632
- <K>(first: ReadonlyMap<K, V>, second: ReadonlyMap<K, V>): ReadonlyMap<K, V>;
633
- <K>(second: ReadonlyMap<K, V>): (first: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
638
+ <K>(first: ReadonlyMap<K, V>, second: ReadonlyMap<K, V>): ReadonlyMap<K, V>;
639
+ <K>(second: ReadonlyMap<K, V>): (first: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
634
640
  };
635
- declare const Dict: {
636
- is: {
637
- empty: <K, V>(m: ReadonlyMap<K, V>) => boolean;
638
- nonEmpty: <K, V>(m: ReadonlyMap<K, V>) => m is NonEmptyMap<K, V>;
639
- };
640
- empty: <K, V>() => ReadonlyMap<K, V>;
641
- singleton: <K, V>(key: K, value: V) => ReadonlyMap<K, V>;
641
+ export declare const Dict: {
642
+ is: {
643
+ empty: <K, V>(m: ReadonlyMap<K, V>) => boolean;
644
+ nonEmpty: <K, V>(m: ReadonlyMap<K, V>) => m is NonEmptyMap<K, V>;
645
+ };
646
+ empty: <K, V>() => ReadonlyMap<K, V>;
647
+ singleton: <K, V>(key: K, value: V) => ReadonlyMap<K, V>;
648
+ from: {
649
+ entries: <K, V>(entries: readonly (readonly [K, V])[]) => ReadonlyMap<K, V>;
650
+ Record: <K extends string, V>(record: Readonly<Record<K, V>>) => ReadonlyMap<K, V>;
651
+ Array: <K, V>(data: readonly (readonly [K, V])[]) => ReadonlyMap<K, V>;
652
+ nullable: <K, V>(data: ReadonlyMap<K, V> | null | undefined) => Maybe<ReadonlyMap<K, V>>;
653
+ };
654
+ to: {
655
+ Record: <K extends string, V>(map: ReadonlyMap<K, V>) => Readonly<Record<K, V>>;
656
+ };
657
+ groupBy: <A, K>(f: (a: A) => K) => (as: readonly A[]) => ReadonlyMap<K, NonEmptyArr<A>>;
658
+ has: <K, V>(key: K) => (data: ReadonlyMap<K, V>) => boolean;
659
+ lookup: <K, V>(key: K) => (data: ReadonlyMap<K, V>) => Maybe<V>;
660
+ size: <K, V>(data: ReadonlyMap<K, V>) => number;
661
+ keys: <K, V>(data: ReadonlyMap<K, V>) => readonly K[];
662
+ values: <K, V>(data: ReadonlyMap<K, V>) => readonly V[];
663
+ entries: <K, V>(data: ReadonlyMap<K, V>) => readonly (readonly [K, V])[];
664
+ insert: <K, V>(key: K, value: V) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
665
+ remove: <K, V>(key: K) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
666
+ upsert: <K, V>(key: K, f: (existing: Maybe<V>) => V) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
667
+ map: <A, B>(f: (a: A) => B) => <K>(data: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
668
+ mapWithKey: <K, A, B>(f: (key: K, value: A) => B) => (data: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
669
+ filter: <A>(predicate: (a: A) => boolean) => <K>(data: ReadonlyMap<K, A>) => ReadonlyMap<K, A>;
670
+ filterWithKey: <K, A>(predicate: (key: K, value: A) => boolean) => (data: ReadonlyMap<K, A>) => ReadonlyMap<K, A>;
671
+ compact: <K, A>(data: ReadonlyMap<K, Maybe<A>>) => ReadonlyMap<K, A>;
672
+ filterMap: <A, B>(f: (a: A) => Maybe<B>) => <K>(data: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
673
+ union: <K, V>(other: ReadonlyMap<K, V>) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
674
+ intersection: <K, V>(other: ReadonlyMap<K, V>) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
675
+ difference: <K, V>(other: ReadonlyMap<K, V>) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
676
+ reduce: <B, V>(init: B, f: (acc: B, value: V) => B) => <K>(data: ReadonlyMap<K, V>) => B;
677
+ reduceWithKey: <B, K, V>(init: B, f: (acc: B, value: V, key: K) => B) => (data: ReadonlyMap<K, V>) => B;
678
+ mergeWith: typeof mergeWith$1;
679
+ mapEntries: <K1, V1, K2, V2>(f: (key: K1, value: V1) => readonly [K2, V2]) => (data: ReadonlyMap<K1, V1>) => ReadonlyMap<K2, V2>;
680
+ mapKeys: <K1, K2, V>(f: (key: K1) => K2) => (data: ReadonlyMap<K1, V>) => ReadonlyMap<K2, V>;
681
+ NonEmpty: {
682
+ singleton: <K, V>(key: K, value: V) => NonEmptyMap<K, V>;
642
683
  from: {
643
- entries: <K, V>(entries: readonly (readonly [K, V])[]) => ReadonlyMap<K, V>;
644
- Record: <K extends string, V>(record: Readonly<Record<K, V>>) => ReadonlyMap<K, V>;
645
- Array: <K, V>(data: readonly (readonly [K, V])[]) => ReadonlyMap<K, V>;
646
- nullable: <K, V>(data: ReadonlyMap<K, V> | null | undefined) => Maybe<ReadonlyMap<K, V>>;
647
- };
648
- to: {
649
- Record: <K extends string, V>(map: ReadonlyMap<K, V>) => Readonly<Record<K, V>>;
650
- };
651
- groupBy: <A, K>(f: (a: A) => K) => (as: readonly A[]) => ReadonlyMap<K, NonEmptyArr<A>>;
652
- has: <K, V>(key: K) => (data: ReadonlyMap<K, V>) => boolean;
653
- lookup: <K, V>(key: K) => (data: ReadonlyMap<K, V>) => Maybe<V>;
654
- size: <K, V>(data: ReadonlyMap<K, V>) => number;
655
- keys: <K, V>(data: ReadonlyMap<K, V>) => readonly K[];
656
- values: <K, V>(data: ReadonlyMap<K, V>) => readonly V[];
657
- entries: <K, V>(data: ReadonlyMap<K, V>) => readonly (readonly [K, V])[];
658
- insert: <K, V>(key: K, value: V) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
659
- remove: <K, V>(key: K) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
660
- upsert: <K, V>(key: K, f: (existing: Maybe<V>) => V) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
661
- map: <A, B>(f: (a: A) => B) => <K>(data: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
662
- mapWithKey: <K, A, B>(f: (key: K, value: A) => B) => (data: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
663
- filter: <A>(predicate: (a: A) => boolean) => <K>(data: ReadonlyMap<K, A>) => ReadonlyMap<K, A>;
664
- filterWithKey: <K, A>(predicate: (key: K, value: A) => boolean) => (data: ReadonlyMap<K, A>) => ReadonlyMap<K, A>;
665
- compact: <K, A>(data: ReadonlyMap<K, Maybe<A>>) => ReadonlyMap<K, A>;
666
- filterMap: <A, B>(f: (a: A) => Maybe<B>) => <K>(data: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
667
- union: <K, V>(other: ReadonlyMap<K, V>) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
668
- intersection: <K, V>(other: ReadonlyMap<K, V>) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
669
- difference: <K, V>(other: ReadonlyMap<K, V>) => (data: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
670
- reduce: <B, V>(init: B, f: (acc: B, value: V) => B) => <K>(data: ReadonlyMap<K, V>) => B;
671
- reduceWithKey: <B, K, V>(init: B, f: (acc: B, value: V, key: K) => B) => (data: ReadonlyMap<K, V>) => B;
672
- mergeWith: typeof mergeWith$1;
673
- mapEntries: <K1, V1, K2, V2>(f: (key: K1, value: V1) => readonly [K2, V2]) => (data: ReadonlyMap<K1, V1>) => ReadonlyMap<K2, V2>;
674
- mapKeys: <K1, K2, V>(f: (key: K1) => K2) => (data: ReadonlyMap<K1, V>) => ReadonlyMap<K2, V>;
675
- NonEmpty: {
676
- singleton: <K, V>(key: K, value: V) => NonEmptyMap<K, V>;
677
- from: {
678
- Map: <K, V>(m: ReadonlyMap<K, V>) => Maybe<NonEmptyMap<K, V>>;
679
- };
680
- keys: <K, V>(m: NonEmptyMap<K, V>) => NonEmptyArr<K>;
681
- values: <K, V>(m: NonEmptyMap<K, V>) => NonEmptyArr<V>;
682
- entries: <K, V>(m: NonEmptyMap<K, V>) => NonEmptyArr<readonly [K, V]>;
683
- reduce: <V>(f: (acc: V, value: V) => V) => <K>(m: NonEmptyMap<K, V>) => V;
684
- map: <A, B>(f: (a: A) => B) => <K>(m: NonEmptyMap<K, A>) => NonEmptyMap<K, B>;
685
- mapWithKey: <K, A, B>(f: (key: K, a: A) => B) => (m: NonEmptyMap<K, A>) => NonEmptyMap<K, B>;
684
+ Map: <K, V>(m: ReadonlyMap<K, V>) => Maybe<NonEmptyMap<K, V>>;
686
685
  };
686
+ keys: <K, V>(m: NonEmptyMap<K, V>) => NonEmptyArr<K>;
687
+ values: <K, V>(m: NonEmptyMap<K, V>) => NonEmptyArr<V>;
688
+ entries: <K, V>(m: NonEmptyMap<K, V>) => NonEmptyArr<readonly [K, V]>;
689
+ reduce: <V>(f: (acc: V, value: V) => V) => <K>(m: NonEmptyMap<K, V>) => V;
690
+ map: <A, B>(f: (a: A) => B) => <K>(m: NonEmptyMap<K, A>) => NonEmptyMap<K, B>;
691
+ mapWithKey: <K, A, B>(f: (key: K, a: A) => B) => (m: NonEmptyMap<K, A>) => NonEmptyMap<K, B>;
692
+ };
687
693
  };
688
- declare namespace Dict {
689
- /**
690
- * A branded type representing a key-value dictionary with at least one entry.
691
- */
692
- type NonEmpty<K, V> = NonEmptyMap<K, V>;
694
+ export declare namespace Dict {
695
+ /**
696
+ * A branded type representing a key-value dictionary with at least one entry.
697
+ */
698
+ type NonEmpty<K, V> = NonEmptyMap<K, V>;
693
699
  }
694
-
700
+ //#endregion
701
+ //#region src/Data/Json.d.ts
695
702
  /**
696
703
  * Pure, non-throwing JSON utilities.
697
704
  * Wraps runtime JSON parsing and stringifying in typed `Result` containers.
@@ -707,349 +714,351 @@ declare namespace Dict {
707
714
  * ); // Ok("Alice")
708
715
  * ```
709
716
  */
710
- declare const Json: {
711
- /**
712
- * Safely parses a JSON string into `unknown`.
713
- * Converts thrown exceptions into a `Result<SyntaxError, unknown>`.
714
- *
715
- * @example
716
- * ```ts
717
- * Json.parse('{"a": 1}'); // Ok({ a: 1 })
718
- * Json.parse('{invalid}'); // Err(SyntaxError)
719
- * ```
720
- */
721
- parse: (text: string) => Result<SyntaxError, unknown>;
722
- /**
723
- * Safely stringifies a value into a JSON string.
724
- * Converts thrown exceptions (e.g. circular references) into a `Result<TypeError, string>`.
725
- *
726
- * @example
727
- * ```ts
728
- * Json.stringify({ a: 1 }); // Ok('{"a":1}')
729
- * ```
730
- */
731
- stringify: (value: unknown, replacer?: (this: any, key: string, value: any) => any, space?: string | number) => Result<TypeError, string>;
717
+ export declare const Json: {
718
+ /**
719
+ * Safely parses a JSON string into `unknown`.
720
+ * Converts thrown exceptions into a `Result<SyntaxError, unknown>`.
721
+ *
722
+ * @example
723
+ * ```ts
724
+ * Json.parse('{"a": 1}'); // Ok({ a: 1 })
725
+ * Json.parse('{invalid}'); // Err(SyntaxError)
726
+ * ```
727
+ */
728
+ parse: (text: string) => Result<SyntaxError, unknown>;
729
+ /**
730
+ * Safely stringifies a value into a JSON string.
731
+ * Converts thrown exceptions (e.g. circular references) into a `Result<TypeError, string>`.
732
+ *
733
+ * @example
734
+ * ```ts
735
+ * Json.stringify({ a: 1 }); // Ok('{"a":1}')
736
+ * ```
737
+ */
738
+ stringify: (value: unknown, replacer?: (this: any, key: string, value: any) => any, space?: string | number) => Result<TypeError, string>;
732
739
  };
733
-
734
- declare const Num: {
735
- is: {
736
- /**
737
- * Returns `true` when the number is equal to zero.
738
- *
739
- * @example
740
- * ```ts
741
- * Num.is.zero(0); // true
742
- * Num.is.zero(5); // false
743
- * ```
744
- */
745
- zero: (n: number) => boolean;
746
- /**
747
- * Returns `true` when the number is a whole integer.
748
- *
749
- * @example
750
- * ```ts
751
- * Num.is.integer(5); // true
752
- * Num.is.integer(3.14); // false
753
- * ```
754
- */
755
- integer: (n: number) => boolean;
756
- /**
757
- * Returns `true` when the number is a finite float (fractional number).
758
- *
759
- * @example
760
- * ```ts
761
- * Num.is.float(3.14); // true
762
- * Num.is.float(5); // false
763
- * ```
764
- */
765
- float: (n: number) => boolean;
766
- /**
767
- * Returns `true` when the number is finite (not `Infinity`, `-Infinity`, or `NaN`).
768
- *
769
- * @example
770
- * ```ts
771
- * Num.is.finite(42); // true
772
- * Num.is.finite(Infinity); // false
773
- * ```
774
- */
775
- finite: (n: number) => boolean;
776
- /**
777
- * Returns `true` when the value is `NaN`.
778
- *
779
- * @example
780
- * ```ts
781
- * Num.is.nan(NaN); // true
782
- * Num.is.nan(42); // false
783
- * ```
784
- */
785
- nan: (n: number) => boolean;
786
- /**
787
- * Returns `true` when the number is an even integer.
788
- *
789
- * @example
790
- * ```ts
791
- * Num.is.even(4); // true
792
- * Num.is.even(3); // false
793
- * Num.is.even(2.5); // false
794
- * ```
795
- */
796
- even: (n: number) => boolean;
797
- /**
798
- * Returns `true` when the number is an odd integer.
799
- *
800
- * @example
801
- * ```ts
802
- * Num.is.odd(3); // true
803
- * Num.is.odd(4); // false
804
- * Num.is.odd(2.5); // false
805
- * ```
806
- */
807
- odd: (n: number) => boolean;
808
- /**
809
- * Returns `true` when the number is strictly greater than zero.
810
- *
811
- * @example
812
- * ```ts
813
- * Num.is.positive(5); // true
814
- * Num.is.positive(0); // false
815
- * Num.is.positive(-5); // false
816
- * ```
817
- */
818
- positive: (n: number) => boolean;
819
- /**
820
- * Returns `true` when the number is strictly less than zero.
821
- *
822
- * @example
823
- * ```ts
824
- * Num.is.negative(-5); // true
825
- * Num.is.negative(0); // false
826
- * Num.is.negative(5); // false
827
- * ```
828
- */
829
- negative: (n: number) => boolean;
830
- };
831
- /**
832
- * Generates an array of numbers from `from` to `to` (both inclusive),
833
- * stepping by `step` (default `1`). If `step` is negative or zero, or `from > to`,
834
- * returns an empty array. When `step` does not land exactly on `to`, the last value
835
- * is the largest reachable value that does not exceed `to`.
836
- *
837
- * @example
838
- * ```ts
839
- * Num.range(0, 5); // [0, 1, 2, 3, 4, 5]
840
- * Num.range(0, 10, 2); // [0, 2, 4, 6, 8, 10]
841
- * Num.range(0, 9, 2); // [0, 2, 4, 6, 8]
842
- * Num.range(5, 0); // []
843
- * Num.range(3, 3); // [3]
844
- * ```
845
- */
846
- range: (from: number, to: number, step?: number) => readonly number[];
847
- /**
848
- * Clamps a number between `min` and `max` (both inclusive).
849
- *
850
- * @example
851
- * ```ts
852
- * pipe(150, Num.clamp(0, 100)); // 100
853
- * pipe(-5, Num.clamp(0, 100)); // 0
854
- * pipe(42, Num.clamp(0, 100)); // 42
855
- * ```
856
- */
857
- clamp: (min: number, max: number) => (n: number) => number;
858
- /**
859
- * Returns `true` when the number is between `min` and `max` (both inclusive).
860
- *
861
- * @example
862
- * ```ts
863
- * pipe(5, Num.between(1, 10)); // true
864
- * pipe(0, Num.between(1, 10)); // false
865
- * pipe(10, Num.between(1, 10)); // true
866
- * ```
867
- */
868
- between: (min: number, max: number) => (n: number) => boolean;
869
- /**
870
- * Returns `true` when the number is in the range `[start, end)` (inclusive of `start`, exclusive of `end`).
871
- *
872
- * @example
873
- * ```ts
874
- * pipe(5, Num.inRange(1, 10)); // true
875
- * pipe(1, Num.inRange(1, 10)); // true
876
- * pipe(10, Num.inRange(1, 10)); // false
877
- * ```
878
- */
879
- inRange: (start: number, end: number) => (n: number) => boolean;
880
- /**
881
- * Parses a string as a number. Returns `None` when the result is `NaN`.
882
- *
883
- * @example
884
- * ```ts
885
- * Num.parse("42"); // Some(42)
886
- * Num.parse("3.14"); // Some(3.14)
887
- * Num.parse("abc"); // None
888
- * Num.parse(""); // None
889
- * ```
890
- */
891
- parse: (s: string) => Maybe<number>;
892
- /**
893
- * Adds `b` to a number. Data-last: use in `pipe` or `Arr.map`.
894
- *
895
- * @example
896
- * ```ts
897
- * pipe(5, Num.add(3)); // 8
898
- * pipe([1, 2, 3], Arr.map(Num.add(10))); // [11, 12, 13]
899
- * ```
900
- */
901
- add: (b: number) => (a: number) => number;
902
- /**
903
- * Subtracts `b` from a number. Data-last: `subtract(b)(a)` = `a - b`.
904
- *
905
- * @example
906
- * ```ts
907
- * pipe(10, Num.subtract(3)); // 7
908
- * pipe([5, 10, 15], Arr.map(Num.subtract(2))); // [3, 8, 13]
909
- * ```
910
- */
911
- subtract: (b: number) => (a: number) => number;
912
- /**
913
- * Multiplies a number by `b`. Data-last: use in `pipe` or `Arr.map`.
914
- *
915
- * @example
916
- * ```ts
917
- * pipe(6, Num.multiply(7)); // 42
918
- * pipe([1, 2, 3], Arr.map(Num.multiply(100))); // [100, 200, 300]
919
- * ```
920
- */
921
- multiply: (b: number) => (a: number) => number;
922
- /**
923
- * Divides a number by `b`. Returns `None` when `b` is zero. Data-last: `divide(b)(a)` = `a / b`.
924
- *
925
- * @example
926
- * ```ts
927
- * pipe(20, Num.divide(4)); // Some(5)
928
- * pipe(5, Num.divide(0)); // None
929
- * pipe([10, 20, 30], Arr.filterMap(Num.divide(10))); // [1, 2, 3]
930
- * ```
931
- */
932
- divide: (b: number) => (a: number) => Maybe<number>;
933
- /**
934
- * Returns the absolute value of a number.
935
- *
936
- * @example
937
- * ```ts
938
- * pipe(-5, Num.abs); // 5
939
- * pipe(5, Num.abs); // 5
940
- * ```
941
- */
942
- abs: (n: number) => number;
740
+ //#endregion
741
+ //#region src/Data/Num.d.ts
742
+ export declare const Num: {
743
+ is: {
943
744
  /**
944
- * Negates a number (arithmetic negation).
745
+ * Returns `true` when the number is equal to zero.
945
746
  *
946
747
  * @example
947
748
  * ```ts
948
- * pipe(5, Num.negate); // -5
949
- * pipe(-5, Num.negate); // 5
749
+ * Num.is.zero(0); // true
750
+ * Num.is.zero(5); // false
950
751
  * ```
951
752
  */
952
- negate: (n: number) => number;
753
+ zero: (n: number) => boolean;
953
754
  /**
954
- * Rounds a number to the nearest integer.
755
+ * Returns `true` when the number is a whole integer.
955
756
  *
956
757
  * @example
957
758
  * ```ts
958
- * pipe(3.5, Num.round); // 4
959
- * pipe(3.4, Num.round); // 3
759
+ * Num.is.integer(5); // true
760
+ * Num.is.integer(3.14); // false
960
761
  * ```
961
762
  */
962
- round: (n: number) => number;
763
+ integer: (n: number) => boolean;
963
764
  /**
964
- * Rounds a number down to the nearest integer.
765
+ * Returns `true` when the number is a finite float (fractional number).
965
766
  *
966
767
  * @example
967
768
  * ```ts
968
- * pipe(3.9, Num.floor); // 3
969
- * pipe(-3.2, Num.floor); // -4
769
+ * Num.is.float(3.14); // true
770
+ * Num.is.float(5); // false
970
771
  * ```
971
772
  */
972
- floor: (n: number) => number;
773
+ float: (n: number) => boolean;
973
774
  /**
974
- * Rounds a number up to the nearest integer.
775
+ * Returns `true` when the number is finite (not `Infinity`, `-Infinity`, or `NaN`).
975
776
  *
976
777
  * @example
977
778
  * ```ts
978
- * pipe(3.1, Num.ceil); // 4
979
- * pipe(-3.9, Num.ceil); // -3
779
+ * Num.is.finite(42); // true
780
+ * Num.is.finite(Infinity); // false
980
781
  * ```
981
782
  */
982
- ceil: (n: number) => number;
783
+ finite: (n: number) => boolean;
983
784
  /**
984
- * Returns the remainder of dividing a number by `divisor`. Returns `None` when `divisor` is zero.
985
- * Data-last: `remainder(divisor)(a)` = `a % divisor`.
785
+ * Returns `true` when the value is `NaN`.
986
786
  *
987
787
  * @example
988
788
  * ```ts
989
- * pipe(10, Num.remainder(3)); // Some(1)
990
- * pipe(5, Num.remainder(0)); // None
991
- * pipe([10, 11, 12], Arr.filterMap(Num.remainder(3))); // [1, 2, 0]
789
+ * Num.is.nan(NaN); // true
790
+ * Num.is.nan(42); // false
992
791
  * ```
993
792
  */
994
- remainder: (divisor: number) => (n: number) => Maybe<number>;
793
+ nan: (n: number) => boolean;
995
794
  /**
996
- * Computes the sum of a list of numbers. Returns `0` if the list is empty.
795
+ * Returns `true` when the number is an even integer.
997
796
  *
998
797
  * @example
999
798
  * ```ts
1000
- * Num.sum([1, 2, 3]); // 6
1001
- * Num.sum([]); // 0
799
+ * Num.is.even(4); // true
800
+ * Num.is.even(3); // false
801
+ * Num.is.even(2.5); // false
1002
802
  * ```
1003
803
  */
1004
- sum: (ns: readonly number[]) => number;
804
+ even: (n: number) => boolean;
1005
805
  /**
1006
- * Computes the mean of a list of numbers. Returns `None` if the list is empty.
806
+ * Returns `true` when the number is an odd integer.
1007
807
  *
1008
808
  * @example
1009
809
  * ```ts
1010
- * Num.mean([1, 2, 3]); // Some(2)
1011
- * Num.mean([]); // None
810
+ * Num.is.odd(3); // true
811
+ * Num.is.odd(4); // false
812
+ * Num.is.odd(2.5); // false
1012
813
  * ```
1013
814
  */
1014
- mean: (ns: readonly number[]) => Maybe<number>;
815
+ odd: (n: number) => boolean;
1015
816
  /**
1016
- * Computes the minimum of a list of numbers. Returns `None` if the list is empty.
817
+ * Returns `true` when the number is strictly greater than zero.
1017
818
  *
1018
819
  * @example
1019
820
  * ```ts
1020
- * Num.min([5, 1, 3]); // Some(1)
1021
- * Num.min([]); // None
821
+ * Num.is.positive(5); // true
822
+ * Num.is.positive(0); // false
823
+ * Num.is.positive(-5); // false
1022
824
  * ```
1023
825
  */
1024
- min: (ns: readonly number[]) => Maybe<number>;
826
+ positive: (n: number) => boolean;
1025
827
  /**
1026
- * Computes the maximum of a list of numbers. Returns `None` if the list is empty.
828
+ * Returns `true` when the number is strictly less than zero.
1027
829
  *
1028
830
  * @example
1029
831
  * ```ts
1030
- * Num.max([1, 5, 3]); // Some(5)
1031
- * Num.max([]); // None
832
+ * Num.is.negative(-5); // true
833
+ * Num.is.negative(0); // false
834
+ * Num.is.negative(5); // false
1032
835
  * ```
1033
836
  */
1034
- max: (ns: readonly number[]) => Maybe<number>;
1035
- /**
1036
- * Formats a number using `Intl.NumberFormat`. Returns `None` when `n` is `NaN` or non-finite.
1037
- * Data-last curried signature.
1038
- *
1039
- * @example
1040
- * ```ts
1041
- * const formatCurrency = Num.format({ style: "currency", currency: "USD" }, "en-US");
1042
- * pipe(1234.5, formatCurrency); // Some("$1,234.50")
1043
- * pipe(NaN, formatCurrency); // None
1044
- * ```
1045
- */
1046
- format: (options?: Intl.NumberFormatOptions, locales?: string | string[]) => (n: number) => Maybe<string>;
837
+ negative: (n: number) => boolean;
838
+ };
839
+ /**
840
+ * Generates an array of numbers from `from` to `to` (both inclusive),
841
+ * stepping by `step` (default `1`). If `step` is negative or zero, or `from > to`,
842
+ * returns an empty array. When `step` does not land exactly on `to`, the last value
843
+ * is the largest reachable value that does not exceed `to`.
844
+ *
845
+ * @example
846
+ * ```ts
847
+ * Num.range(0, 5); // [0, 1, 2, 3, 4, 5]
848
+ * Num.range(0, 10, 2); // [0, 2, 4, 6, 8, 10]
849
+ * Num.range(0, 9, 2); // [0, 2, 4, 6, 8]
850
+ * Num.range(5, 0); // []
851
+ * Num.range(3, 3); // [3]
852
+ * ```
853
+ */
854
+ range: (from: number, to: number, step?: number) => readonly number[];
855
+ /**
856
+ * Clamps a number between `min` and `max` (both inclusive).
857
+ *
858
+ * @example
859
+ * ```ts
860
+ * pipe(150, Num.clamp(0, 100)); // 100
861
+ * pipe(-5, Num.clamp(0, 100)); // 0
862
+ * pipe(42, Num.clamp(0, 100)); // 42
863
+ * ```
864
+ */
865
+ clamp: (min: number, max: number) => (n: number) => number;
866
+ /**
867
+ * Returns `true` when the number is between `min` and `max` (both inclusive).
868
+ *
869
+ * @example
870
+ * ```ts
871
+ * pipe(5, Num.between(1, 10)); // true
872
+ * pipe(0, Num.between(1, 10)); // false
873
+ * pipe(10, Num.between(1, 10)); // true
874
+ * ```
875
+ */
876
+ between: (min: number, max: number) => (n: number) => boolean;
877
+ /**
878
+ * Returns `true` when the number is in the range `[start, end)` (inclusive of `start`, exclusive of `end`).
879
+ *
880
+ * @example
881
+ * ```ts
882
+ * pipe(5, Num.inRange(1, 10)); // true
883
+ * pipe(1, Num.inRange(1, 10)); // true
884
+ * pipe(10, Num.inRange(1, 10)); // false
885
+ * ```
886
+ */
887
+ inRange: (start: number, end: number) => (n: number) => boolean;
888
+ /**
889
+ * Parses a string as a number. Returns `None` when the result is `NaN`.
890
+ *
891
+ * @example
892
+ * ```ts
893
+ * Num.parse("42"); // Some(42)
894
+ * Num.parse("3.14"); // Some(3.14)
895
+ * Num.parse("abc"); // None
896
+ * Num.parse(""); // None
897
+ * ```
898
+ */
899
+ parse: (s: string) => Maybe<number>;
900
+ /**
901
+ * Adds `b` to a number. Data-last: use in `pipe` or `Arr.map`.
902
+ *
903
+ * @example
904
+ * ```ts
905
+ * pipe(5, Num.add(3)); // 8
906
+ * pipe([1, 2, 3], Arr.map(Num.add(10))); // [11, 12, 13]
907
+ * ```
908
+ */
909
+ add: (b: number) => (a: number) => number;
910
+ /**
911
+ * Subtracts `b` from a number. Data-last: `subtract(b)(a)` = `a - b`.
912
+ *
913
+ * @example
914
+ * ```ts
915
+ * pipe(10, Num.subtract(3)); // 7
916
+ * pipe([5, 10, 15], Arr.map(Num.subtract(2))); // [3, 8, 13]
917
+ * ```
918
+ */
919
+ subtract: (b: number) => (a: number) => number;
920
+ /**
921
+ * Multiplies a number by `b`. Data-last: use in `pipe` or `Arr.map`.
922
+ *
923
+ * @example
924
+ * ```ts
925
+ * pipe(6, Num.multiply(7)); // 42
926
+ * pipe([1, 2, 3], Arr.map(Num.multiply(100))); // [100, 200, 300]
927
+ * ```
928
+ */
929
+ multiply: (b: number) => (a: number) => number;
930
+ /**
931
+ * Divides a number by `b`. Returns `None` when `b` is zero. Data-last: `divide(b)(a)` = `a / b`.
932
+ *
933
+ * @example
934
+ * ```ts
935
+ * pipe(20, Num.divide(4)); // Some(5)
936
+ * pipe(5, Num.divide(0)); // None
937
+ * pipe([10, 20, 30], Arr.filterMap(Num.divide(10))); // [1, 2, 3]
938
+ * ```
939
+ */
940
+ divide: (b: number) => (a: number) => Maybe<number>;
941
+ /**
942
+ * Returns the absolute value of a number.
943
+ *
944
+ * @example
945
+ * ```ts
946
+ * pipe(-5, Num.abs); // 5
947
+ * pipe(5, Num.abs); // 5
948
+ * ```
949
+ */
950
+ abs: (n: number) => number;
951
+ /**
952
+ * Negates a number (arithmetic negation).
953
+ *
954
+ * @example
955
+ * ```ts
956
+ * pipe(5, Num.negate); // -5
957
+ * pipe(-5, Num.negate); // 5
958
+ * ```
959
+ */
960
+ negate: (n: number) => number;
961
+ /**
962
+ * Rounds a number to the nearest integer.
963
+ *
964
+ * @example
965
+ * ```ts
966
+ * pipe(3.5, Num.round); // 4
967
+ * pipe(3.4, Num.round); // 3
968
+ * ```
969
+ */
970
+ round: (n: number) => number;
971
+ /**
972
+ * Rounds a number down to the nearest integer.
973
+ *
974
+ * @example
975
+ * ```ts
976
+ * pipe(3.9, Num.floor); // 3
977
+ * pipe(-3.2, Num.floor); // -4
978
+ * ```
979
+ */
980
+ floor: (n: number) => number;
981
+ /**
982
+ * Rounds a number up to the nearest integer.
983
+ *
984
+ * @example
985
+ * ```ts
986
+ * pipe(3.1, Num.ceil); // 4
987
+ * pipe(-3.9, Num.ceil); // -3
988
+ * ```
989
+ */
990
+ ceil: (n: number) => number;
991
+ /**
992
+ * Returns the remainder of dividing a number by `divisor`. Returns `None` when `divisor` is zero.
993
+ * Data-last: `remainder(divisor)(a)` = `a % divisor`.
994
+ *
995
+ * @example
996
+ * ```ts
997
+ * pipe(10, Num.remainder(3)); // Some(1)
998
+ * pipe(5, Num.remainder(0)); // None
999
+ * pipe([10, 11, 12], Arr.filterMap(Num.remainder(3))); // [1, 2, 0]
1000
+ * ```
1001
+ */
1002
+ remainder: (divisor: number) => (n: number) => Maybe<number>;
1003
+ /**
1004
+ * Computes the sum of a list of numbers. Returns `0` if the list is empty.
1005
+ *
1006
+ * @example
1007
+ * ```ts
1008
+ * Num.sum([1, 2, 3]); // 6
1009
+ * Num.sum([]); // 0
1010
+ * ```
1011
+ */
1012
+ sum: (ns: readonly number[]) => number;
1013
+ /**
1014
+ * Computes the mean of a list of numbers. Returns `None` if the list is empty.
1015
+ *
1016
+ * @example
1017
+ * ```ts
1018
+ * Num.mean([1, 2, 3]); // Some(2)
1019
+ * Num.mean([]); // None
1020
+ * ```
1021
+ */
1022
+ mean: (ns: readonly number[]) => Maybe<number>;
1023
+ /**
1024
+ * Computes the minimum of a list of numbers. Returns `None` if the list is empty.
1025
+ *
1026
+ * @example
1027
+ * ```ts
1028
+ * Num.min([5, 1, 3]); // Some(1)
1029
+ * Num.min([]); // None
1030
+ * ```
1031
+ */
1032
+ min: (ns: readonly number[]) => Maybe<number>;
1033
+ /**
1034
+ * Computes the maximum of a list of numbers. Returns `None` if the list is empty.
1035
+ *
1036
+ * @example
1037
+ * ```ts
1038
+ * Num.max([1, 5, 3]); // Some(5)
1039
+ * Num.max([]); // None
1040
+ * ```
1041
+ */
1042
+ max: (ns: readonly number[]) => Maybe<number>;
1043
+ /**
1044
+ * Formats a number using `Intl.NumberFormat`. Returns `None` when `n` is `NaN` or non-finite.
1045
+ * Data-last curried signature.
1046
+ *
1047
+ * @example
1048
+ * ```ts
1049
+ * const formatCurrency = Num.format({ style: "currency", currency: "USD" }, "en-US");
1050
+ * pipe(1234.5, formatCurrency); // Some("$1,234.50")
1051
+ * pipe(NaN, formatCurrency); // None
1052
+ * ```
1053
+ */
1054
+ format: (options?: Intl.NumberFormatOptions, locales?: string | string[]) => (n: number) => Maybe<string>;
1047
1055
  };
1048
-
1056
+ //#endregion
1057
+ //#region src/Data/Rec.d.ts
1049
1058
  /**
1050
1059
  * A branded type representing a record with at least one key-value pair.
1051
1060
  */
1052
- type NonEmptyRecord<A, K extends string = string> = Brand<NonEmpty<"Rec">, Readonly<Record<K, A>>>;
1061
+ export type NonEmptyRecord<A, K extends string = string> = Brand<NonEmpty<"Rec">, Readonly<Record<K, A>>>;
1053
1062
  /**
1054
1063
  * Merges two records using a custom combination function on key collisions.
1055
1064
  * Supports both uncurried `Rec.mergeWith(combine)(first, second)` and curried `pipe(first, Rec.mergeWith(combine)(second))`.
@@ -1062,407 +1071,420 @@ type NonEmptyRecord<A, K extends string = string> = Brand<NonEmpty<"Rec">, Reado
1062
1071
  * ```
1063
1072
  */
1064
1073
  declare function mergeWith<A>(combine: (a: A, b: A) => A): {
1065
- (second: Readonly<Record<string, A>>): (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1066
- (first: Readonly<Record<string, A>>, second: Readonly<Record<string, A>>): Readonly<Record<string, A>>;
1074
+ (second: Readonly<Record<string, A>>): (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1075
+ (first: Readonly<Record<string, A>>, second: Readonly<Record<string, A>>): Readonly<Record<string, A>>;
1067
1076
  };
1068
- declare const Rec: {
1069
- is: {
1070
- /**
1071
- * Returns true if the record has no keys.
1072
- *
1073
- * @example
1074
- * ```ts
1075
- * Rec.is.empty({}); // true
1076
- * Rec.is.empty({ a: 1 }); // false
1077
- * ```
1078
- */
1079
- empty: <A>(data: Readonly<Record<string, A>>) => boolean;
1080
- /**
1081
- * Type guard to check if a record is non-empty.
1082
- *
1083
- * @example
1084
- * ```ts
1085
- * Rec.is.nonEmpty({ a: 1 }); // true
1086
- * Rec.is.nonEmpty({}); // false
1087
- * ```
1088
- */
1089
- nonEmpty: <A, K extends string>(data: Readonly<Record<K, A>>) => data is NonEmptyRecord<A, K>;
1090
- };
1091
- from: {
1092
- /**
1093
- * Creates a record from key-value pairs.
1094
- *
1095
- * @example
1096
- * ```ts
1097
- * Rec.from.entries([["a", 1], ["b", 2]]); // { a: 1, b: 2 }
1098
- * ```
1099
- */
1100
- entries: <A>(data: readonly (readonly [string, A])[]) => Readonly<Record<string, A>>;
1101
- };
1102
- to: {
1103
- Dict: <A, K extends string = string>(data: Readonly<Record<K, A>>) => ReadonlyMap<K, A>;
1104
- };
1105
- map: <A, B>(f: (a: A) => B) => <K extends string>(data: Readonly<Record<K, A>>) => Readonly<Record<K, B>>;
1106
- filterMap: <A, B>(f: (a: A) => Maybe<B>) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, B>>;
1107
- mapWithKey: <A, B>(f: (key: string, a: A) => B) => <K extends string>(data: Readonly<Record<K, A>>) => Readonly<Record<K, B>>;
1108
- filter: <A>(predicate: (a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1109
- filterWithKey: <A>(predicate: (key: string, a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1110
- lookup: <K extends string>(key: K) => <V>(data: Record<string, V>) => Maybe<V>;
1111
- keys: <T extends Record<string, unknown>>(data: T) => readonly (keyof T & string)[];
1112
- values: <T extends Record<string, unknown>>(data: T) => readonly T[keyof T & string][];
1113
- entries: <T extends Record<string, unknown>>(data: T) => readonly (readonly [keyof T, T[keyof T]])[];
1114
- groupBy: <A>(keyFn: (a: A) => string) => (items: readonly A[]) => Readonly<Record<string, readonly A[]>>;
1115
- pick: <K extends string>(...pickedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Pick<A, K>;
1116
- omit: <K extends string>(...omittedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Omit<A, K>;
1117
- merge: <A>(other: Readonly<Record<string, A>>) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1118
- mergeWith: typeof mergeWith;
1119
- size: <A>(data: Readonly<Record<string, A>>) => number;
1120
- mapKeys: (f: (key: string) => string) => <A>(data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1121
- compact: <A>(data: Readonly<Record<string, Maybe<A>>>) => Readonly<Record<string, A>>;
1122
- mapEntries: <A, K2 extends string, B>(f: (key: string, value: A) => readonly [K2, B]) => (data: Readonly<Record<string, A>>) => Readonly<Record<K2, B>>;
1123
- updateIn: <T>(path: readonly [string, ...string[]], f: (val: T) => T) => (data: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>>;
1124
- traverse: {
1125
- Maybe: <A, B>(f: (a: A) => Maybe<B>) => (data: Readonly<Record<string, A>>) => Maybe<Readonly<Record<string, B>>>;
1126
- Result: <E, A, B>(f: (a: A) => Result<E, B>) => (data: Readonly<Record<string, A>>) => Result<E, Readonly<Record<string, B>>>;
1127
- };
1128
- sequence: {
1129
- Maybe: <A>(data: Readonly<Record<string, Maybe<A>>>) => Maybe<Readonly<Record<string, A>>>;
1130
- Result: <E, A>(data: Readonly<Record<string, Result<E, A>>>) => Result<E, Readonly<Record<string, A>>>;
1131
- };
1132
- NonEmpty: {
1133
- singleton: <K extends string, A>(key: K, value: A) => NonEmptyRecord<A, K>;
1134
- from: {
1135
- Record: <K extends string, A>(data: Readonly<Record<K, A>>) => Maybe<NonEmptyRecord<A, K>>;
1136
- };
1137
- keys: <K extends string, A>(data: NonEmptyRecord<A, K>) => NonEmptyArr<K>;
1138
- values: <K extends string, A>(data: NonEmptyRecord<A, K>) => NonEmptyArr<A>;
1139
- entries: <K extends string, A>(data: NonEmptyRecord<A, K>) => NonEmptyArr<readonly [K, A]>;
1140
- reduce: <A>(f: (acc: A, a: A) => A) => <K extends string>(data: NonEmptyRecord<A, K>) => A;
1141
- map: <A, B>(f: (a: A) => B) => <K extends string>(data: NonEmptyRecord<A, K>) => NonEmptyRecord<B, K>;
1142
- mapWithKey: <A, B>(f: (key: string, a: A) => B) => <K extends string>(data: NonEmptyRecord<A, K>) => NonEmptyRecord<B, K>;
1143
- };
1144
- };
1145
- declare namespace Rec {
1146
- type NonEmpty<A, K extends string = string> = NonEmptyRecord<A, K>;
1147
- }
1148
-
1149
- /**
1150
- * A branded type representing a string with at least one character.
1151
- */
1152
- type NonEmptyString = Brand<NonEmpty<"Str">, string>;
1153
- declare const Str: {
1154
- is: {
1155
- /**
1156
- * Returns `true` when the string is empty.
1157
- *
1158
- * @example
1159
- * ```ts
1160
- * pipe("", Str.is.empty); // true
1161
- * pipe("hi", Str.is.empty); // false
1162
- * ```
1163
- */
1164
- empty: (s: string) => boolean;
1165
- /**
1166
- * Type guard to check if a string is non-empty.
1167
- */
1168
- nonEmpty: (s: string) => s is NonEmptyString;
1169
- };
1170
- /**
1171
- * Splits a string by a separator. Data-last: use in `pipe`.
1172
- *
1173
- * @example
1174
- * ```ts
1175
- * pipe("a,b,c", Str.split(",")); // ["a", "b", "c"]
1176
- * ```
1177
- */
1178
- split: (separator: string | RegExp) => (s: string) => readonly string[];
1179
- /**
1180
- * Removes leading and trailing whitespace from a string.
1181
- *
1182
- * @example
1183
- * ```ts
1184
- * pipe(" hello ", Str.trim); // "hello"
1185
- * ```
1186
- */
1187
- trim: (s: string) => string;
1077
+ export declare const Rec: {
1078
+ is: {
1188
1079
  /**
1189
- * Returns `true` when the string contains the given substring.
1080
+ * Returns true if the record has no keys.
1190
1081
  *
1191
1082
  * @example
1192
1083
  * ```ts
1193
- * pipe("hello world", Str.includes("world")); // true
1194
- * pipe("hello world", Str.includes("xyz")); // false
1084
+ * Rec.is.empty({}); // true
1085
+ * Rec.is.empty({ a: 1 }); // false
1195
1086
  * ```
1196
1087
  */
1197
- includes: (substring: string) => (s: string) => boolean;
1088
+ empty: <A>(data: Readonly<Record<string, A>>) => boolean;
1198
1089
  /**
1199
- * Replaces the first occurrence of a pattern in a string. Data-last: use in `pipe`.
1090
+ * Type guard to check if a record is non-empty.
1200
1091
  *
1201
1092
  * @example
1202
1093
  * ```ts
1203
- * pipe("foo foo foo", Str.replace("foo", "bar")); // "bar foo foo"
1204
- * pipe("Hello World", Str.replace(/world/i, "Earth")); // "Hello Earth"
1094
+ * Rec.is.nonEmpty({ a: 1 }); // true
1095
+ * Rec.is.nonEmpty({}); // false
1205
1096
  * ```
1206
1097
  */
1207
- replace: (pattern: string | RegExp, replacement: string) => (s: string) => string;
1098
+ nonEmpty: <A, K extends string>(data: Readonly<Record<K, A>>) => data is NonEmptyRecord<A, K>;
1099
+ };
1100
+ from: {
1208
1101
  /**
1209
- * Replaces all occurrences of a pattern in a string. Data-last: use in `pipe`.
1102
+ * Creates a record from key-value pairs.
1210
1103
  *
1211
1104
  * @example
1212
1105
  * ```ts
1213
- * pipe("foo foo foo", Str.replaceAll("foo", "bar")); // "bar bar bar"
1214
- * pipe("aAbBaA", Str.replaceAll(/a/gi, "x")); // "xxBBxx"
1106
+ * Rec.from.entries([["a", 1], ["b", 2]]); // { a: 1, b: 2 }
1215
1107
  * ```
1216
1108
  */
1217
- replaceAll: (pattern: string | RegExp, replacement: string) => (s: string) => string;
1218
- /**
1219
- * Returns `true` when the string starts with the given prefix.
1220
- *
1221
- * @example
1222
- * ```ts
1223
- * pipe("hello world", Str.startsWith("hello")); // true
1224
- * pipe("hello world", Str.startsWith("world")); // false
1225
- * ```
1226
- */
1227
- startsWith: (prefix: string) => (s: string) => boolean;
1228
- /**
1229
- * Returns `true` when the string ends with the given suffix.
1230
- *
1231
- * @example
1232
- * ```ts
1233
- * pipe("hello world", Str.endsWith("world")); // true
1234
- * pipe("hello world", Str.endsWith("hello")); // false
1235
- * ```
1236
- */
1237
- endsWith: (suffix: string) => (s: string) => boolean;
1238
- /**
1239
- * Converts a string to uppercase.
1240
- *
1241
- * @example
1242
- * ```ts
1243
- * pipe("hello", Str.toUpperCase); // "HELLO"
1244
- * ```
1245
- */
1246
- toUpperCase: (s: string) => string;
1247
- /**
1248
- * Converts a string to lowercase.
1249
- *
1250
- * @example
1251
- * ```ts
1252
- * pipe("HELLO", Str.toLowerCase); // "hello"
1253
- * ```
1254
- */
1255
- toLowerCase: (s: string) => string;
1256
- /**
1257
- * Converts the first character of a string to uppercase.
1258
- *
1259
- * @example
1260
- * ```ts
1261
- * pipe("hello", Str.capitalize); // "Hello"
1262
- * ```
1263
- */
1264
- capitalize: (s: string) => string;
1265
- /**
1266
- * Splits a string into lines, normalising `\r\n` and `\r` line endings.
1267
- *
1268
- * @example
1269
- * ```ts
1270
- * Str.lines("one\ntwo\nthree"); // ["one", "two", "three"]
1271
- * Str.lines("a\r\nb"); // ["a", "b"]
1272
- * ```
1273
- */
1274
- lines: (s: string) => readonly string[];
1275
- /**
1276
- * Splits a string into words on any whitespace boundary, filtering out empty strings.
1277
- *
1278
- * @example
1279
- * ```ts
1280
- * Str.words(" hello world "); // ["hello", "world"]
1281
- * ```
1282
- */
1283
- words: (s: string) => readonly string[];
1284
- /**
1285
- * Returns `true` when the string is empty or contains only whitespace.
1286
- *
1287
- * @example
1288
- * ```ts
1289
- * pipe(" ", Str.isBlank); // true
1290
- * pipe("hi", Str.isBlank); // false
1291
- * ```
1292
- */
1293
- isBlank: (s: string) => boolean;
1294
- /**
1295
- * Returns the length of the string.
1296
- *
1297
- * @example
1298
- * ```ts
1299
- * pipe("hello", Str.length); // 5
1300
- * pipe("", Str.length); // 0
1301
- * ```
1302
- */
1303
- length: (s: string) => number;
1304
- /**
1305
- * Extracts a substring between two indices. Data-last: use in `pipe`.
1306
- *
1307
- * @example
1308
- * ```ts
1309
- * pipe("hello", Str.slice(1, 3)); // "el"
1310
- * pipe("hello", Str.slice(2)); // "llo"
1311
- * ```
1312
- */
1313
- slice: (start: number, end?: number) => (s: string) => string;
1314
- /**
1315
- * Pads the start of a string to a specified length. Data-last: use in `pipe`.
1316
- *
1317
- * @example
1318
- * ```ts
1319
- * pipe("5", Str.padStart(3, "0")); // "005"
1320
- * pipe("hi", Str.padStart(5)); // " hi"
1321
- * ```
1322
- */
1323
- padStart: (maxLength: number, fillString?: string) => (s: string) => string;
1324
- /**
1325
- * Pads the end of a string to a specified length. Data-last: use in `pipe`.
1326
- *
1327
- * @example
1328
- * ```ts
1329
- * pipe("hi", Str.padEnd(5, ".")); // "hi..."
1330
- * pipe("hi", Str.padEnd(5)); // "hi "
1331
- * ```
1332
- */
1333
- padEnd: (maxLength: number, fillString?: string) => (s: string) => string;
1334
- /**
1335
- * Safe number parsers that return `Maybe` instead of `NaN`.
1336
- */
1337
- parse: {
1338
- /**
1339
- * Parses a string as an integer (base 10). Returns `None` if the result is `NaN`.
1340
- *
1341
- * @example
1342
- * ```ts
1343
- * Str.parse.int("42"); // Some(42)
1344
- * Str.parse.int("3.7"); // Some(3)
1345
- * Str.parse.int("abc"); // None
1346
- * ```
1347
- */
1348
- int: (s: string) => Maybe<number>;
1349
- /**
1350
- * Parses a string as a floating-point number. Returns `None` if the result is `NaN`.
1351
- *
1352
- * @example
1353
- * ```ts
1354
- * Str.parse.float("3.14"); // Some(3.14)
1355
- * Str.parse.float("42"); // Some(42)
1356
- * Str.parse.float("abc"); // None
1357
- * ```
1358
- */
1359
- float: (s: string) => Maybe<number>;
1109
+ entries: <A>(data: readonly (readonly [string, A])[]) => Readonly<Record<string, A>>;
1110
+ };
1111
+ to: {
1112
+ Dict: <A, K extends string = string>(data: Readonly<Record<K, A>>) => ReadonlyMap<K, A>;
1113
+ };
1114
+ map: <A, B>(f: (a: A) => B) => <K extends string>(data: Readonly<Record<K, A>>) => Readonly<Record<K, B>>;
1115
+ filterMap: <A, B>(f: (a: A) => Maybe<B>) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, B>>;
1116
+ mapWithKey: <A, B>(f: (key: string, a: A) => B) => <K extends string>(data: Readonly<Record<K, A>>) => Readonly<Record<K, B>>;
1117
+ filter: <A>(predicate: (a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1118
+ filterWithKey: <A>(predicate: (key: string, a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1119
+ lookup: <K extends string>(key: K) => <V>(data: Record<string, V>) => Maybe<V>;
1120
+ keys: <T extends Record<string, unknown>>(data: T) => readonly (keyof T & string)[];
1121
+ values: <T extends Record<string, unknown>>(data: T) => readonly T[keyof T & string][];
1122
+ entries: <T extends Record<string, unknown>>(data: T) => readonly (readonly [keyof T, T[keyof T]])[];
1123
+ groupBy: <A>(keyFn: (a: A) => string) => (items: readonly A[]) => Readonly<Record<string, readonly A[]>>;
1124
+ pick: <K extends string>(...pickedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Pick<A, K>;
1125
+ omit: <K extends string>(...omittedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Omit<A, K>;
1126
+ merge: <A>(other: Readonly<Record<string, A>>) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1127
+ mergeWith: typeof mergeWith;
1128
+ size: <A>(data: Readonly<Record<string, A>>) => number;
1129
+ mapKeys: (f: (key: string) => string) => <A>(data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
1130
+ compact: <A>(data: Readonly<Record<string, Maybe<A>>>) => Readonly<Record<string, A>>;
1131
+ mapEntries: <A, K2 extends string, B>(f: (key: string, value: A) => readonly [K2, B]) => (data: Readonly<Record<string, A>>) => Readonly<Record<K2, B>>;
1132
+ updateIn: <T>(path: readonly [string, ...string[]], f: (val: T) => T) => (data: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>>;
1133
+ traverse: {
1134
+ Maybe: <A, B>(f: (a: A) => Maybe<B>) => (data: Readonly<Record<string, A>>) => Maybe<Readonly<Record<string, B>>>;
1135
+ Result: <E, A, B>(f: (a: A) => Result<E, B>) => (data: Readonly<Record<string, A>>) => Result<E, Readonly<Record<string, B>>>;
1136
+ };
1137
+ sequence: {
1138
+ Maybe: <A>(data: Readonly<Record<string, Maybe<A>>>) => Maybe<Readonly<Record<string, A>>>;
1139
+ Result: <E, A>(data: Readonly<Record<string, Result<E, A>>>) => Result<E, Readonly<Record<string, A>>>;
1140
+ };
1141
+ NonEmpty: {
1142
+ singleton: <K extends string, A>(key: K, value: A) => NonEmptyRecord<A, K>;
1143
+ from: {
1144
+ Record: <K extends string, A>(data: Readonly<Record<K, A>>) => Maybe<NonEmptyRecord<A, K>>;
1360
1145
  };
1361
- /**
1362
- * Safely parses a JSON string, returning a `Result<SyntaxError, unknown>`.
1363
- *
1364
- * @example
1365
- * ```ts
1366
- * Str.parseJson('{"a": 1}'); // Ok({ a: 1 })
1367
- * Str.parseJson('invalid'); // Err(SyntaxError)
1368
- * ```
1369
- */
1370
- parseJson: (s: string) => Result<SyntaxError, unknown>;
1371
- /**
1372
- * Converts the first character of a string to lower case.
1373
- *
1374
- * @example
1375
- * ```ts
1376
- * Str.uncapitalize("Hello"); // "hello"
1377
- * Str.uncapitalize(""); // ""
1378
- * ```
1379
- */
1380
- uncapitalize: (s: string) => string;
1381
- /**
1382
- * Truncates a string to a maximum length, appending an optional suffix (default `"..."`).
1383
- * Data-last curried signature.
1384
- *
1385
- * @example
1386
- * ```ts
1387
- * pipe("Hello, world!", Str.truncate({ length: 8 })); // "Hello..."
1388
- * pipe("Hello", Str.truncate({ length: 10 })); // "Hello"
1389
- * pipe("Hello, world!", Str.truncate({ length: 8, suffix: "…" })); // "Hello, w…"
1390
- * ```
1391
- */
1392
- truncate: (options: {
1393
- length: number;
1394
- suffix?: string;
1395
- }) => (s: string) => string;
1396
- NonEmpty: {
1397
- from: {
1398
- /**
1399
- * Returns Some containing NonEmptyString if the string is not empty, None otherwise.
1400
- *
1401
- * @example
1402
- * ```ts
1403
- * Str.NonEmpty.from.String("hello"); // Some("hello")
1404
- * Str.NonEmpty.from.String(""); // None
1405
- * ```
1406
- */
1407
- String: (s: string) => Maybe<NonEmptyString>;
1408
- };
1146
+ keys: <K extends string, A>(data: NonEmptyRecord<A, K>) => NonEmptyArr<K>;
1147
+ values: <K extends string, A>(data: NonEmptyRecord<A, K>) => NonEmptyArr<A>;
1148
+ entries: <K extends string, A>(data: NonEmptyRecord<A, K>) => NonEmptyArr<readonly [K, A]>;
1149
+ reduce: <A>(f: (acc: A, a: A) => A) => <K extends string>(data: NonEmptyRecord<A, K>) => A;
1150
+ map: <A, B>(f: (a: A) => B) => <K extends string>(data: NonEmptyRecord<A, K>) => NonEmptyRecord<B, K>;
1151
+ mapWithKey: <A, B>(f: (key: string, a: A) => B) => <K extends string>(data: NonEmptyRecord<A, K>) => NonEmptyRecord<B, K>;
1152
+ };
1153
+ };
1154
+ export declare namespace Rec {
1155
+ type NonEmpty<A, K extends string = string> = NonEmptyRecord<A, K>;
1156
+ }
1157
+ //#endregion
1158
+ //#region src/Data/Str.d.ts
1159
+ /**
1160
+ * A branded type representing a string with at least one character.
1161
+ */
1162
+ export type NonEmptyString = Brand<NonEmpty<"Str">, string>;
1163
+ export declare const Str: {
1164
+ is: {
1165
+ /**
1166
+ * Returns `true` when the string is empty.
1167
+ *
1168
+ * @example
1169
+ * ```ts
1170
+ * pipe("", Str.is.empty); // true
1171
+ * pipe("hi", Str.is.empty); // false
1172
+ * ```
1173
+ */
1174
+ empty: (s: string) => boolean;
1175
+ /**
1176
+ * Type guard to check if a string is non-empty.
1177
+ */
1178
+ nonEmpty: (s: string) => s is NonEmptyString;
1179
+ };
1180
+ /**
1181
+ * Splits a string by a separator. Data-last: use in `pipe`.
1182
+ *
1183
+ * @example
1184
+ * ```ts
1185
+ * pipe("a,b,c", Str.split(",")); // ["a", "b", "c"]
1186
+ * ```
1187
+ */
1188
+ split: (separator: string | RegExp) => (s: string) => readonly string[];
1189
+ /**
1190
+ * Removes leading and trailing whitespace from a string.
1191
+ *
1192
+ * @example
1193
+ * ```ts
1194
+ * pipe(" hello ", Str.trim); // "hello"
1195
+ * ```
1196
+ */
1197
+ trim: (s: string) => string;
1198
+ /**
1199
+ * Returns `true` when the string contains the given substring.
1200
+ *
1201
+ * @example
1202
+ * ```ts
1203
+ * pipe("hello world", Str.includes("world")); // true
1204
+ * pipe("hello world", Str.includes("xyz")); // false
1205
+ * ```
1206
+ */
1207
+ includes: (substring: string) => (s: string) => boolean;
1208
+ /**
1209
+ * Replaces the first occurrence of a pattern in a string. Data-last: use in `pipe`.
1210
+ *
1211
+ * @example
1212
+ * ```ts
1213
+ * pipe("foo foo foo", Str.replace("foo", "bar")); // "bar foo foo"
1214
+ * pipe("Hello World", Str.replace(/world/i, "Earth")); // "Hello Earth"
1215
+ * ```
1216
+ */
1217
+ replace: (pattern: string | RegExp, replacement: string) => (s: string) => string;
1218
+ /**
1219
+ * Replaces all occurrences of a pattern in a string. Data-last: use in `pipe`.
1220
+ *
1221
+ * @example
1222
+ * ```ts
1223
+ * pipe("foo foo foo", Str.replaceAll("foo", "bar")); // "bar bar bar"
1224
+ * pipe("aAbBaA", Str.replaceAll(/a/gi, "x")); // "xxBBxx"
1225
+ * ```
1226
+ */
1227
+ replaceAll: (pattern: string | RegExp, replacement: string) => (s: string) => string;
1228
+ /**
1229
+ * Returns `true` when the string starts with the given prefix.
1230
+ *
1231
+ * @example
1232
+ * ```ts
1233
+ * pipe("hello world", Str.startsWith("hello")); // true
1234
+ * pipe("hello world", Str.startsWith("world")); // false
1235
+ * ```
1236
+ */
1237
+ startsWith: (prefix: string) => (s: string) => boolean;
1238
+ /**
1239
+ * Returns `true` when the string ends with the given suffix.
1240
+ *
1241
+ * @example
1242
+ * ```ts
1243
+ * pipe("hello world", Str.endsWith("world")); // true
1244
+ * pipe("hello world", Str.endsWith("hello")); // false
1245
+ * ```
1246
+ */
1247
+ endsWith: (suffix: string) => (s: string) => boolean;
1248
+ /**
1249
+ * Converts a string to uppercase.
1250
+ *
1251
+ * @example
1252
+ * ```ts
1253
+ * pipe("hello", Str.toUpperCase); // "HELLO"
1254
+ * ```
1255
+ */
1256
+ toUpperCase: (s: string) => string;
1257
+ /**
1258
+ * Converts a string to lowercase.
1259
+ *
1260
+ * @example
1261
+ * ```ts
1262
+ * pipe("HELLO", Str.toLowerCase); // "hello"
1263
+ * ```
1264
+ */
1265
+ toLowerCase: (s: string) => string;
1266
+ /**
1267
+ * Converts the first character of a string to uppercase.
1268
+ *
1269
+ * @example
1270
+ * ```ts
1271
+ * pipe("hello", Str.capitalize); // "Hello"
1272
+ * ```
1273
+ */
1274
+ capitalize: (s: string) => string;
1275
+ /**
1276
+ * Splits a string into lines, normalising `\r\n` and `\r` line endings.
1277
+ *
1278
+ * @example
1279
+ * ```ts
1280
+ * Str.lines("one\ntwo\nthree"); // ["one", "two", "three"]
1281
+ * Str.lines("a\r\nb"); // ["a", "b"]
1282
+ * ```
1283
+ */
1284
+ lines: (s: string) => readonly string[];
1285
+ /**
1286
+ * Splits a string into words on any whitespace boundary, filtering out empty strings.
1287
+ *
1288
+ * @example
1289
+ * ```ts
1290
+ * Str.words(" hello world "); // ["hello", "world"]
1291
+ * ```
1292
+ */
1293
+ words: (s: string) => readonly string[];
1294
+ /**
1295
+ * Returns `true` when the string is empty or contains only whitespace.
1296
+ *
1297
+ * @example
1298
+ * ```ts
1299
+ * pipe(" ", Str.isBlank); // true
1300
+ * pipe("hi", Str.isBlank); // false
1301
+ * ```
1302
+ */
1303
+ isBlank: (s: string) => boolean;
1304
+ /**
1305
+ * Returns the length of the string.
1306
+ *
1307
+ * @example
1308
+ * ```ts
1309
+ * pipe("hello", Str.length); // 5
1310
+ * pipe("", Str.length); // 0
1311
+ * ```
1312
+ */
1313
+ length: (s: string) => number;
1314
+ /**
1315
+ * Extracts a substring between two indices. Data-last: use in `pipe`.
1316
+ *
1317
+ * @example
1318
+ * ```ts
1319
+ * pipe("hello", Str.slice(1, 3)); // "el"
1320
+ * pipe("hello", Str.slice(2)); // "llo"
1321
+ * ```
1322
+ */
1323
+ slice: (start: number, end?: number) => (s: string) => string;
1324
+ /**
1325
+ * Pads the start of a string to a specified length. Data-last: use in `pipe`.
1326
+ *
1327
+ * @example
1328
+ * ```ts
1329
+ * pipe("5", Str.padStart(3, "0")); // "005"
1330
+ * pipe("hi", Str.padStart(5)); // " hi"
1331
+ * ```
1332
+ */
1333
+ padStart: (maxLength: number, fillString?: string) => (s: string) => string;
1334
+ /**
1335
+ * Pads the end of a string to a specified length. Data-last: use in `pipe`.
1336
+ *
1337
+ * @example
1338
+ * ```ts
1339
+ * pipe("hi", Str.padEnd(5, ".")); // "hi..."
1340
+ * pipe("hi", Str.padEnd(5)); // "hi "
1341
+ * ```
1342
+ */
1343
+ padEnd: (maxLength: number, fillString?: string) => (s: string) => string;
1344
+ /**
1345
+ * Safe number parsers that return `Maybe` instead of `NaN`.
1346
+ */
1347
+ parse: {
1348
+ /**
1349
+ * Parses a string as an integer (base 10). Returns `None` if the result is `NaN`.
1350
+ *
1351
+ * @example
1352
+ * ```ts
1353
+ * Str.parse.int("42"); // Some(42)
1354
+ * Str.parse.int("3.7"); // Some(3)
1355
+ * Str.parse.int("abc"); // None
1356
+ * ```
1357
+ */
1358
+ int: (s: string) => Maybe<number>;
1359
+ /**
1360
+ * Parses a string as a floating-point number. Returns `None` if the result is `NaN`.
1361
+ *
1362
+ * @example
1363
+ * ```ts
1364
+ * Str.parse.float("3.14"); // Some(3.14)
1365
+ * Str.parse.float("42"); // Some(42)
1366
+ * Str.parse.float("abc"); // None
1367
+ * ```
1368
+ */
1369
+ float: (s: string) => Maybe<number>;
1370
+ };
1371
+ /**
1372
+ * Matches a string against a regular expression.
1373
+ * Pure and safe: resets `pattern.lastIndex = 0` to prevent bugs with stateful `/g` and `/y` regexes.
1374
+ *
1375
+ * @example
1376
+ * ```ts
1377
+ * pipe("hello 42", Str.match(/\d+/)); // Some(["42"])
1378
+ * pipe("hello", Str.match(/\d+/)); // None
1379
+ * ```
1380
+ */
1381
+ match: (pattern: RegExp) => (s: string) => Maybe<RegExpMatchArray>;
1382
+ /**
1383
+ * Tests whether a string matches a regular expression.
1384
+ * Pure and safe: resets `pattern.lastIndex = 0` to prevent bugs with stateful `/g` and `/y` regexes.
1385
+ *
1386
+ * @example
1387
+ * ```ts
1388
+ * pipe("user@example.com", Str.test(/^[^@]+@[^@]+$/)); // true
1389
+ * pipe("invalid-email", Str.test(/^[^@]+@[^@]+$/)); // false
1390
+ * ```
1391
+ */
1392
+ test: (pattern: RegExp) => (s: string) => boolean;
1393
+ /**
1394
+ * Converts the first character of a string to lower case.
1395
+ *
1396
+ * @example
1397
+ * ```ts
1398
+ * Str.uncapitalize("Hello"); // "hello"
1399
+ * Str.uncapitalize(""); // ""
1400
+ * ```
1401
+ */
1402
+ uncapitalize: (s: string) => string;
1403
+ /**
1404
+ * Truncates a string to a maximum length, appending an optional suffix (default `"..."`).
1405
+ * Data-last curried signature.
1406
+ *
1407
+ * @example
1408
+ * ```ts
1409
+ * pipe("Hello, world!", Str.truncate({ length: 8 })); // "Hello..."
1410
+ * pipe("Hello", Str.truncate({ length: 10 })); // "Hello"
1411
+ * pipe("Hello, world!", Str.truncate({ length: 8, suffix: "…" })); // "Hello, w…"
1412
+ * ```
1413
+ */
1414
+ truncate: (options: {
1415
+ length: number;
1416
+ suffix?: string;
1417
+ }) => (s: string) => string;
1418
+ NonEmpty: {
1419
+ from: {
1420
+ /**
1421
+ * Returns Some containing NonEmptyString if the string is not empty, None otherwise.
1422
+ *
1423
+ * @example
1424
+ * ```ts
1425
+ * Str.NonEmpty.from.String("hello"); // Some("hello")
1426
+ * Str.NonEmpty.from.String(""); // None
1427
+ * ```
1428
+ */
1429
+ String: (s: string) => Maybe<NonEmptyString>;
1409
1430
  };
1431
+ };
1410
1432
  };
1411
- declare namespace Str {
1412
- /**
1413
- * A branded type representing a string with at least one character.
1414
- */
1415
- type NonEmpty = NonEmptyString;
1433
+ export declare namespace Str {
1434
+ /**
1435
+ * A branded type representing a string with at least one character.
1436
+ */
1437
+ type NonEmpty = NonEmptyString;
1416
1438
  }
1417
-
1439
+ //#endregion
1440
+ //#region src/Data/Uniq.d.ts
1418
1441
  /**
1419
1442
  * A branded type representing a unique collection with at least one element.
1420
1443
  */
1421
- type NonEmptySet<A> = Brand<NonEmpty<"Uniq">, ReadonlySet<A>>;
1422
- declare const Uniq: {
1423
- is: {
1424
- empty: <A>(s: ReadonlySet<A>) => boolean;
1425
- nonEmpty: <A>(s: ReadonlySet<A>) => s is NonEmptySet<A>;
1426
- };
1427
- empty: <A>() => ReadonlySet<A>;
1428
- singleton: <A>(item: A) => ReadonlySet<A>;
1444
+ export type NonEmptySet<A> = Brand<NonEmpty<"Uniq">, ReadonlySet<A>>;
1445
+ export declare const Uniq: {
1446
+ is: {
1447
+ empty: <A>(s: ReadonlySet<A>) => boolean;
1448
+ nonEmpty: <A>(s: ReadonlySet<A>) => s is NonEmptySet<A>;
1449
+ };
1450
+ empty: <A>() => ReadonlySet<A>;
1451
+ singleton: <A>(item: A) => ReadonlySet<A>;
1452
+ from: {
1453
+ Array: <A>(arr: readonly A[]) => ReadonlySet<A>;
1454
+ };
1455
+ has: <A>(item: A) => (s: ReadonlySet<A>) => boolean;
1456
+ size: <A>(s: ReadonlySet<A>) => number;
1457
+ add: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1458
+ insert: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1459
+ remove: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1460
+ toggle: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1461
+ map: <A, B>(f: (a: A) => B) => (s: ReadonlySet<A>) => ReadonlySet<B>;
1462
+ filter: <A>(predicate: (a: A) => boolean) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1463
+ filterMap: <A, B>(f: (a: A) => Maybe<B>) => (s: ReadonlySet<A>) => ReadonlySet<B>;
1464
+ union: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1465
+ intersection: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1466
+ difference: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1467
+ isSubsetOf: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => boolean;
1468
+ reduce: <A, B>(init: B, f: (acc: B, a: A) => B) => (s: ReadonlySet<A>) => B;
1469
+ to: {
1470
+ Array: <A>(s: ReadonlySet<A>) => readonly A[];
1471
+ };
1472
+ NonEmpty: {
1473
+ singleton: <A>(item: A) => NonEmptySet<A>;
1429
1474
  from: {
1430
- Array: <A>(arr: readonly A[]) => ReadonlySet<A>;
1475
+ Set: <A>(s: ReadonlySet<A>) => Maybe<NonEmptySet<A>>;
1431
1476
  };
1432
- has: <A>(item: A) => (s: ReadonlySet<A>) => boolean;
1433
- size: <A>(s: ReadonlySet<A>) => number;
1434
- add: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1435
- insert: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1436
- remove: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1437
- toggle: <A>(item: A) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1438
- map: <A, B>(f: (a: A) => B) => (s: ReadonlySet<A>) => ReadonlySet<B>;
1439
- filter: <A>(predicate: (a: A) => boolean) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1440
- filterMap: <A, B>(f: (a: A) => Maybe<B>) => (s: ReadonlySet<A>) => ReadonlySet<B>;
1441
- union: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1442
- intersection: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1443
- difference: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => ReadonlySet<A>;
1444
- isSubsetOf: <A>(other: ReadonlySet<A>) => (s: ReadonlySet<A>) => boolean;
1445
- reduce: <A, B>(init: B, f: (acc: B, a: A) => B) => (s: ReadonlySet<A>) => B;
1477
+ reduce: <A>(f: (acc: A, a: A) => A) => (s: NonEmptySet<A>) => A;
1478
+ map: <A, B>(f: (a: A) => B) => (s: NonEmptySet<A>) => NonEmptySet<B>;
1446
1479
  to: {
1447
- Array: <A>(s: ReadonlySet<A>) => readonly A[];
1448
- };
1449
- NonEmpty: {
1450
- singleton: <A>(item: A) => NonEmptySet<A>;
1451
- from: {
1452
- Set: <A>(s: ReadonlySet<A>) => Maybe<NonEmptySet<A>>;
1453
- };
1454
- reduce: <A>(f: (acc: A, a: A) => A) => (s: NonEmptySet<A>) => A;
1455
- map: <A, B>(f: (a: A) => B) => (s: NonEmptySet<A>) => NonEmptySet<B>;
1456
- to: {
1457
- Array: <A>(s: NonEmptySet<A>) => NonEmptyArr<A>;
1458
- };
1480
+ Array: <A>(s: NonEmptySet<A>) => NonEmptyArr<A>;
1459
1481
  };
1482
+ };
1460
1483
  };
1461
- declare namespace Uniq {
1462
- /**
1463
- * A branded type representing a unique collection with at least one element.
1464
- */
1465
- type NonEmpty<A> = NonEmptySet<A>;
1484
+ export declare namespace Uniq {
1485
+ /**
1486
+ * A branded type representing a unique collection with at least one element.
1487
+ */
1488
+ type NonEmpty<A> = NonEmptySet<A>;
1466
1489
  }
1467
-
1468
- export { Arr, BigNum, Bool, type BoolMatchCases, Dict, Json, type NonEmptyMap, type NonEmptyRecord, type NonEmptySet, type NonEmptyString, Num, Rec, Str, Uniq };
1490
+ //#endregion