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