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