@nlozgachev/pipelined 0.64.0 → 0.65.0

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