@nlozgachev/pipelined 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Task-7brqoQrb.d.ts → Task-C8Pgm7EX.d.ts} +23 -0
- package/dist/{Task-BoqaFsUR.d.mts → Task-vQb3-puQ.d.mts} +23 -0
- package/dist/{chunk-Z3DYYR43.mjs → chunk-HHCRWQYN.mjs} +2 -0
- package/dist/{chunk-6H373E63.mjs → chunk-SBTMTAZF.mjs} +19 -1
- package/dist/{chunk-NTISCH7Z.mjs → chunk-YYVONF5X.mjs} +2 -1
- package/dist/core.d.mts +13 -2
- package/dist/core.d.ts +13 -2
- package/dist/core.js +3 -0
- package/dist/core.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -0
- package/dist/index.mjs +3 -3
- package/dist/utils.d.mts +133 -1
- package/dist/utils.d.ts +133 -1
- package/dist/utils.js +20 -0
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
|
@@ -263,6 +263,18 @@ declare namespace Result {
|
|
|
263
263
|
* ```
|
|
264
264
|
*/
|
|
265
265
|
const tapError: <E, A>(f: (e: E) => void) => (data: Result<E, A>) => Result<E, A>;
|
|
266
|
+
/**
|
|
267
|
+
* Creates a Result from a predicate applied to a value.
|
|
268
|
+
* Returns Ok if the predicate passes, Err from onFalse otherwise.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* pipe(5, Result.fromPredicate(n => n > 0, n => `${n} is not positive`)); // Ok(5)
|
|
273
|
+
* pipe(-1, Result.fromPredicate(n => n > 0, n => `${n} is not positive`)); // Err("-1 is not positive")
|
|
274
|
+
* pipe("", Result.fromPredicate(s => s.length > 0, () => "empty string")); // Err("empty string")
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
const fromPredicate: <E, A>(pred: (a: A) => boolean, onFalse: (a: A) => E) => (a: A) => Result<E, A>;
|
|
266
278
|
/**
|
|
267
279
|
* Recovers from an error by providing a fallback Result.
|
|
268
280
|
* The fallback can produce a different success type, widening the result to `Result<E, A | B>`.
|
|
@@ -585,6 +597,17 @@ declare namespace Task {
|
|
|
585
597
|
* ```
|
|
586
598
|
*/
|
|
587
599
|
const from: <A>(f: (signal?: AbortSignal) => Promise<A>) => Task<A>;
|
|
600
|
+
/**
|
|
601
|
+
* Creates a Task from a lazy synchronous thunk.
|
|
602
|
+
* Unlike `Task.resolve(f())`, `fromSync` does not evaluate `f` until the Task is called.
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* const t = Task.fromSync(() => Date.now()); // Date.now() not called yet
|
|
607
|
+
* const ts = await t(); // called here, every time
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
const fromSync: <A>(f: () => A) => Task<A>;
|
|
588
611
|
/**
|
|
589
612
|
* Transforms the value inside a Task.
|
|
590
613
|
*
|
|
@@ -263,6 +263,18 @@ declare namespace Result {
|
|
|
263
263
|
* ```
|
|
264
264
|
*/
|
|
265
265
|
const tapError: <E, A>(f: (e: E) => void) => (data: Result<E, A>) => Result<E, A>;
|
|
266
|
+
/**
|
|
267
|
+
* Creates a Result from a predicate applied to a value.
|
|
268
|
+
* Returns Ok if the predicate passes, Err from onFalse otherwise.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* pipe(5, Result.fromPredicate(n => n > 0, n => `${n} is not positive`)); // Ok(5)
|
|
273
|
+
* pipe(-1, Result.fromPredicate(n => n > 0, n => `${n} is not positive`)); // Err("-1 is not positive")
|
|
274
|
+
* pipe("", Result.fromPredicate(s => s.length > 0, () => "empty string")); // Err("empty string")
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
const fromPredicate: <E, A>(pred: (a: A) => boolean, onFalse: (a: A) => E) => (a: A) => Result<E, A>;
|
|
266
278
|
/**
|
|
267
279
|
* Recovers from an error by providing a fallback Result.
|
|
268
280
|
* The fallback can produce a different success type, widening the result to `Result<E, A | B>`.
|
|
@@ -585,6 +597,17 @@ declare namespace Task {
|
|
|
585
597
|
* ```
|
|
586
598
|
*/
|
|
587
599
|
const from: <A>(f: (signal?: AbortSignal) => Promise<A>) => Task<A>;
|
|
600
|
+
/**
|
|
601
|
+
* Creates a Task from a lazy synchronous thunk.
|
|
602
|
+
* Unlike `Task.resolve(f())`, `fromSync` does not evaluate `f` until the Task is called.
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* const t = Task.fromSync(() => Date.now()); // Date.now() not called yet
|
|
607
|
+
* const ts = await t(); // called here, every time
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
const fromSync: <A>(f: () => A) => Task<A>;
|
|
588
611
|
/**
|
|
589
612
|
* Transforms the value inside a Task.
|
|
590
613
|
*
|
|
@@ -65,6 +65,7 @@ var Result;
|
|
|
65
65
|
if ((0, Result2.isErr)(data)) f(data.error);
|
|
66
66
|
return data;
|
|
67
67
|
};
|
|
68
|
+
Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
|
|
68
69
|
Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
|
|
69
70
|
Result2.recoverUnless = (blockedErr, fallback) => (data) => (0, Result2.isErr)(data) && data.error !== blockedErr ? fallback() : data;
|
|
70
71
|
Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
@@ -77,6 +78,7 @@ var Task;
|
|
|
77
78
|
((Task2) => {
|
|
78
79
|
Task2.resolve = (value) => () => Deferred.fromPromise(Promise.resolve(value));
|
|
79
80
|
Task2.from = (f) => (signal) => Deferred.fromPromise(f(signal));
|
|
81
|
+
Task2.fromSync = (f) => () => Deferred.fromPromise(Promise.resolve(f()));
|
|
80
82
|
Task2.map = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then(f));
|
|
81
83
|
Task2.chain = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then((a) => toPromise(f(a), signal)));
|
|
82
84
|
Task2.ap = (arg) => (data) => (0, Task2.from)(
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Maybe,
|
|
4
4
|
Result,
|
|
5
5
|
Task
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HHCRWQYN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
isNonEmptyList
|
|
9
9
|
} from "./chunk-DBIC62UV.mjs";
|
|
@@ -35,6 +35,12 @@ var Arr;
|
|
|
35
35
|
for (let i = 0; i < n; i++) result[i] = f(data[i]);
|
|
36
36
|
return result;
|
|
37
37
|
};
|
|
38
|
+
Arr2.mapWithIndex = (f) => (data) => {
|
|
39
|
+
const n = data.length;
|
|
40
|
+
const result = new Array(n);
|
|
41
|
+
for (let i = 0; i < n; i++) result[i] = f(i, data[i]);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
38
44
|
Arr2.filter = (predicate) => (data) => {
|
|
39
45
|
const n = data.length;
|
|
40
46
|
const result = [];
|
|
@@ -362,6 +368,12 @@ var Num;
|
|
|
362
368
|
Num2.subtract = (b) => (a) => a - b;
|
|
363
369
|
Num2.multiply = (b) => (a) => a * b;
|
|
364
370
|
Num2.divide = (b) => (a) => a / b;
|
|
371
|
+
Num2.abs = (n) => Math.abs(n);
|
|
372
|
+
Num2.negate = (n) => -n;
|
|
373
|
+
Num2.round = (n) => Math.round(n);
|
|
374
|
+
Num2.floor = (n) => Math.floor(n);
|
|
375
|
+
Num2.ceil = (n) => Math.ceil(n);
|
|
376
|
+
Num2.remainder = (divisor) => (n) => n % divisor;
|
|
365
377
|
})(Num || (Num = {}));
|
|
366
378
|
|
|
367
379
|
// src/Utils/Rec.ts
|
|
@@ -487,6 +499,12 @@ var Str;
|
|
|
487
499
|
Str2.toLowerCase = (s) => s.toLowerCase();
|
|
488
500
|
Str2.lines = (s) => s.split(/\r?\n|\r/);
|
|
489
501
|
Str2.words = (s) => s.trim().split(/\s+/).filter(Boolean);
|
|
502
|
+
Str2.isEmpty = (s) => s.length === 0;
|
|
503
|
+
Str2.isBlank = (s) => s.trim().length === 0;
|
|
504
|
+
Str2.length = (s) => s.length;
|
|
505
|
+
Str2.slice = (start, end) => (s) => s.slice(start, end);
|
|
506
|
+
Str2.padStart = (maxLength, fillString) => (s) => s.padStart(maxLength, fillString);
|
|
507
|
+
Str2.padEnd = (maxLength, fillString) => (s) => s.padEnd(maxLength, fillString);
|
|
490
508
|
Str2.parse = {
|
|
491
509
|
/**
|
|
492
510
|
* Parses a string as an integer (base 10). Returns `None` if the result is `NaN`.
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Maybe,
|
|
4
4
|
Result,
|
|
5
5
|
Task
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HHCRWQYN.mjs";
|
|
7
7
|
|
|
8
8
|
// src/Core/Lens.ts
|
|
9
9
|
var Lens;
|
|
@@ -1093,6 +1093,7 @@ var RemoteData;
|
|
|
1093
1093
|
RemoteData2.toMaybe = (data) => (0, RemoteData2.isSuccess)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
1094
1094
|
RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
|
|
1095
1095
|
RemoteData2.fromResult = (data) => Result.isOk(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(data.error);
|
|
1096
|
+
RemoteData2.fromMaybe = (onNone) => (data) => Maybe.isSome(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(onNone());
|
|
1096
1097
|
})(RemoteData || (RemoteData = {}));
|
|
1097
1098
|
|
|
1098
1099
|
// src/Core/Resource.ts
|
package/dist/core.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Maybe, W as WithValue, a as WithLog, D as Deferred, R as Result, b as WithKind, c as WithError, d as RetryOptions, e as TimeoutOptions, f as WithTimeout, g as WithMinInterval, h as WithCooldown, i as WithConcurrency, j as WithSize, k as WithMs, l as WithN, T as Task, m as WithErrors, n as WithFirst, o as WithSecond } from './Task-
|
|
2
|
-
export { E as Err, N as None, O as Ok, S as Some } from './Task-
|
|
1
|
+
import { M as Maybe, W as WithValue, a as WithLog, D as Deferred, R as Result, b as WithKind, c as WithError, d as RetryOptions, e as TimeoutOptions, f as WithTimeout, g as WithMinInterval, h as WithCooldown, i as WithConcurrency, j as WithSize, k as WithMs, l as WithN, T as Task, m as WithErrors, n as WithFirst, o as WithSecond } from './Task-vQb3-puQ.mjs';
|
|
2
|
+
export { E as Err, N as None, O as Ok, S as Some } from './Task-vQb3-puQ.mjs';
|
|
3
3
|
import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
|
|
4
4
|
|
|
5
5
|
/** Keys of T for which undefined is assignable (i.e. optional fields). */
|
|
@@ -1655,6 +1655,17 @@ declare namespace RemoteData {
|
|
|
1655
1655
|
* ```
|
|
1656
1656
|
*/
|
|
1657
1657
|
const fromResult: <E, A>(data: Result<E, A>) => RemoteData<E, A>;
|
|
1658
|
+
/**
|
|
1659
|
+
* Converts a Maybe to a RemoteData.
|
|
1660
|
+
* Some becomes Success, None becomes Failure using the onNone error producer.
|
|
1661
|
+
*
|
|
1662
|
+
* @example
|
|
1663
|
+
* ```ts
|
|
1664
|
+
* pipe(Maybe.some(user), RemoteData.fromMaybe(() => "not found")); // Success(user)
|
|
1665
|
+
* pipe(Maybe.none(), RemoteData.fromMaybe(() => "not found")); // Failure("not found")
|
|
1666
|
+
* ```
|
|
1667
|
+
*/
|
|
1668
|
+
const fromMaybe: <E>(onNone: () => E) => <A>(data: Maybe<A>) => RemoteData<E, A>;
|
|
1658
1669
|
}
|
|
1659
1670
|
|
|
1660
1671
|
/**
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Maybe, W as WithValue, a as WithLog, D as Deferred, R as Result, b as WithKind, c as WithError, d as RetryOptions, e as TimeoutOptions, f as WithTimeout, g as WithMinInterval, h as WithCooldown, i as WithConcurrency, j as WithSize, k as WithMs, l as WithN, T as Task, m as WithErrors, n as WithFirst, o as WithSecond } from './Task-
|
|
2
|
-
export { E as Err, N as None, O as Ok, S as Some } from './Task-
|
|
1
|
+
import { M as Maybe, W as WithValue, a as WithLog, D as Deferred, R as Result, b as WithKind, c as WithError, d as RetryOptions, e as TimeoutOptions, f as WithTimeout, g as WithMinInterval, h as WithCooldown, i as WithConcurrency, j as WithSize, k as WithMs, l as WithN, T as Task, m as WithErrors, n as WithFirst, o as WithSecond } from './Task-C8Pgm7EX.js';
|
|
2
|
+
export { E as Err, N as None, O as Ok, S as Some } from './Task-C8Pgm7EX.js';
|
|
3
3
|
import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.js';
|
|
4
4
|
|
|
5
5
|
/** Keys of T for which undefined is assignable (i.e. optional fields). */
|
|
@@ -1655,6 +1655,17 @@ declare namespace RemoteData {
|
|
|
1655
1655
|
* ```
|
|
1656
1656
|
*/
|
|
1657
1657
|
const fromResult: <E, A>(data: Result<E, A>) => RemoteData<E, A>;
|
|
1658
|
+
/**
|
|
1659
|
+
* Converts a Maybe to a RemoteData.
|
|
1660
|
+
* Some becomes Success, None becomes Failure using the onNone error producer.
|
|
1661
|
+
*
|
|
1662
|
+
* @example
|
|
1663
|
+
* ```ts
|
|
1664
|
+
* pipe(Maybe.some(user), RemoteData.fromMaybe(() => "not found")); // Success(user)
|
|
1665
|
+
* pipe(Maybe.none(), RemoteData.fromMaybe(() => "not found")); // Failure("not found")
|
|
1666
|
+
* ```
|
|
1667
|
+
*/
|
|
1668
|
+
const fromMaybe: <E>(onNone: () => E) => <A>(data: Maybe<A>) => RemoteData<E, A>;
|
|
1658
1669
|
}
|
|
1659
1670
|
|
|
1660
1671
|
/**
|
package/dist/core.js
CHANGED
|
@@ -130,6 +130,7 @@ var Result;
|
|
|
130
130
|
if ((0, Result2.isErr)(data)) f(data.error);
|
|
131
131
|
return data;
|
|
132
132
|
};
|
|
133
|
+
Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
|
|
133
134
|
Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
|
|
134
135
|
Result2.recoverUnless = (blockedErr, fallback) => (data) => (0, Result2.isErr)(data) && data.error !== blockedErr ? fallback() : data;
|
|
135
136
|
Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
@@ -1204,6 +1205,7 @@ var RemoteData;
|
|
|
1204
1205
|
RemoteData2.toMaybe = (data) => (0, RemoteData2.isSuccess)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
1205
1206
|
RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
|
|
1206
1207
|
RemoteData2.fromResult = (data) => Result.isOk(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(data.error);
|
|
1208
|
+
RemoteData2.fromMaybe = (onNone) => (data) => Maybe.isSome(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(onNone());
|
|
1207
1209
|
})(RemoteData || (RemoteData = {}));
|
|
1208
1210
|
|
|
1209
1211
|
// src/Core/Task.ts
|
|
@@ -1212,6 +1214,7 @@ var Task;
|
|
|
1212
1214
|
((Task2) => {
|
|
1213
1215
|
Task2.resolve = (value) => () => Deferred.fromPromise(Promise.resolve(value));
|
|
1214
1216
|
Task2.from = (f) => (signal) => Deferred.fromPromise(f(signal));
|
|
1217
|
+
Task2.fromSync = (f) => () => Deferred.fromPromise(Promise.resolve(f()));
|
|
1215
1218
|
Task2.map = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then(f));
|
|
1216
1219
|
Task2.chain = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then((a) => toPromise(f(a), signal)));
|
|
1217
1220
|
Task2.ap = (arg) => (data) => (0, Task2.from)(
|
package/dist/core.mjs
CHANGED
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
These,
|
|
16
16
|
Tuple,
|
|
17
17
|
Validation
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YYVONF5X.mjs";
|
|
19
19
|
import {
|
|
20
20
|
Deferred,
|
|
21
21
|
Maybe,
|
|
22
22
|
Result,
|
|
23
23
|
Task
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-HHCRWQYN.mjs";
|
|
25
25
|
export {
|
|
26
26
|
Deferred,
|
|
27
27
|
Lens,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { and, compose, constFalse, constNull, constTrue, constUndefined, constVoid, constant, converge, curry, curry3, curry4, flip, flow, identity, juxt, memoize, memoizeWeak, not, on, once, or, pipe, tap, uncurry, uncurry3, uncurry4 } from './composition.mjs';
|
|
2
|
-
export { D as Deferred, E as Err, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-
|
|
2
|
+
export { D as Deferred, E as Err, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-vQb3-puQ.mjs';
|
|
3
3
|
export { Failure, Invalid, Lens, Loading, Logged, NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, State, Success, TaskMaybe, TaskResult, TaskValidation, These, TheseBoth, TheseFirst, TheseSecond, Tuple, Valid, Validation } from './core.mjs';
|
|
4
4
|
export { Brand } from './types.mjs';
|
|
5
5
|
export { N as NonEmptyList, i as isNonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { and, compose, constFalse, constNull, constTrue, constUndefined, constVoid, constant, converge, curry, curry3, curry4, flip, flow, identity, juxt, memoize, memoizeWeak, not, on, once, or, pipe, tap, uncurry, uncurry3, uncurry4 } from './composition.js';
|
|
2
|
-
export { D as Deferred, E as Err, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-
|
|
2
|
+
export { D as Deferred, E as Err, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-C8Pgm7EX.js';
|
|
3
3
|
export { Failure, Invalid, Lens, Loading, Logged, NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, State, Success, TaskMaybe, TaskResult, TaskValidation, These, TheseBoth, TheseFirst, TheseSecond, Tuple, Valid, Validation } from './core.js';
|
|
4
4
|
export { Brand } from './types.js';
|
|
5
5
|
export { N as NonEmptyList, i as isNonEmptyList } from './NonEmptyList-BlGFjor5.js';
|
package/dist/index.js
CHANGED
|
@@ -375,6 +375,7 @@ var Result;
|
|
|
375
375
|
if ((0, Result2.isErr)(data)) f(data.error);
|
|
376
376
|
return data;
|
|
377
377
|
};
|
|
378
|
+
Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
|
|
378
379
|
Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
|
|
379
380
|
Result2.recoverUnless = (blockedErr, fallback) => (data) => (0, Result2.isErr)(data) && data.error !== blockedErr ? fallback() : data;
|
|
380
381
|
Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
@@ -1449,6 +1450,7 @@ var RemoteData;
|
|
|
1449
1450
|
RemoteData2.toMaybe = (data) => (0, RemoteData2.isSuccess)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
1450
1451
|
RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
|
|
1451
1452
|
RemoteData2.fromResult = (data) => Result.isOk(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(data.error);
|
|
1453
|
+
RemoteData2.fromMaybe = (onNone) => (data) => Maybe.isSome(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(onNone());
|
|
1452
1454
|
})(RemoteData || (RemoteData = {}));
|
|
1453
1455
|
|
|
1454
1456
|
// src/Core/Task.ts
|
|
@@ -1457,6 +1459,7 @@ var Task;
|
|
|
1457
1459
|
((Task2) => {
|
|
1458
1460
|
Task2.resolve = (value) => () => Deferred.fromPromise(Promise.resolve(value));
|
|
1459
1461
|
Task2.from = (f) => (signal) => Deferred.fromPromise(f(signal));
|
|
1462
|
+
Task2.fromSync = (f) => () => Deferred.fromPromise(Promise.resolve(f()));
|
|
1460
1463
|
Task2.map = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then(f));
|
|
1461
1464
|
Task2.chain = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then((a) => toPromise(f(a), signal)));
|
|
1462
1465
|
Task2.ap = (arg) => (data) => (0, Task2.from)(
|
|
@@ -1869,6 +1872,12 @@ var Arr;
|
|
|
1869
1872
|
for (let i = 0; i < n; i++) result[i] = f(data[i]);
|
|
1870
1873
|
return result;
|
|
1871
1874
|
};
|
|
1875
|
+
Arr2.mapWithIndex = (f) => (data) => {
|
|
1876
|
+
const n = data.length;
|
|
1877
|
+
const result = new Array(n);
|
|
1878
|
+
for (let i = 0; i < n; i++) result[i] = f(i, data[i]);
|
|
1879
|
+
return result;
|
|
1880
|
+
};
|
|
1872
1881
|
Arr2.filter = (predicate) => (data) => {
|
|
1873
1882
|
const n = data.length;
|
|
1874
1883
|
const result = [];
|
|
@@ -2196,6 +2205,12 @@ var Num;
|
|
|
2196
2205
|
Num2.subtract = (b) => (a) => a - b;
|
|
2197
2206
|
Num2.multiply = (b) => (a) => a * b;
|
|
2198
2207
|
Num2.divide = (b) => (a) => a / b;
|
|
2208
|
+
Num2.abs = (n) => Math.abs(n);
|
|
2209
|
+
Num2.negate = (n) => -n;
|
|
2210
|
+
Num2.round = (n) => Math.round(n);
|
|
2211
|
+
Num2.floor = (n) => Math.floor(n);
|
|
2212
|
+
Num2.ceil = (n) => Math.ceil(n);
|
|
2213
|
+
Num2.remainder = (divisor) => (n) => n % divisor;
|
|
2199
2214
|
})(Num || (Num = {}));
|
|
2200
2215
|
|
|
2201
2216
|
// src/Utils/Rec.ts
|
|
@@ -2321,6 +2336,12 @@ var Str;
|
|
|
2321
2336
|
Str2.toLowerCase = (s) => s.toLowerCase();
|
|
2322
2337
|
Str2.lines = (s) => s.split(/\r?\n|\r/);
|
|
2323
2338
|
Str2.words = (s) => s.trim().split(/\s+/).filter(Boolean);
|
|
2339
|
+
Str2.isEmpty = (s) => s.length === 0;
|
|
2340
|
+
Str2.isBlank = (s) => s.trim().length === 0;
|
|
2341
|
+
Str2.length = (s) => s.length;
|
|
2342
|
+
Str2.slice = (start, end) => (s) => s.slice(start, end);
|
|
2343
|
+
Str2.padStart = (maxLength, fillString) => (s) => s.padStart(maxLength, fillString);
|
|
2344
|
+
Str2.padEnd = (maxLength, fillString) => (s) => s.padEnd(maxLength, fillString);
|
|
2324
2345
|
Str2.parse = {
|
|
2325
2346
|
/**
|
|
2326
2347
|
* Parses a string as an integer (base 10). Returns `None` if the result is `NaN`.
|
package/dist/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
These,
|
|
45
45
|
Tuple,
|
|
46
46
|
Validation
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-YYVONF5X.mjs";
|
|
48
48
|
import {
|
|
49
49
|
Arr,
|
|
50
50
|
Dict,
|
|
@@ -52,13 +52,13 @@ import {
|
|
|
52
52
|
Rec,
|
|
53
53
|
Str,
|
|
54
54
|
Uniq
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-SBTMTAZF.mjs";
|
|
56
56
|
import {
|
|
57
57
|
Deferred,
|
|
58
58
|
Maybe,
|
|
59
59
|
Result,
|
|
60
60
|
Task
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-HHCRWQYN.mjs";
|
|
62
62
|
import {
|
|
63
63
|
Brand
|
|
64
64
|
} from "./chunk-BYWKZLHM.mjs";
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Maybe, R as Result, T as Task } from './Task-
|
|
1
|
+
import { M as Maybe, R as Result, T as Task } from './Task-vQb3-puQ.mjs';
|
|
2
2
|
import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -93,6 +93,18 @@ declare namespace Arr {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
const map: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly B[];
|
|
96
|
+
/**
|
|
97
|
+
* Transforms each element using both its value and its zero-based index.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* pipe(
|
|
102
|
+
* ["a", "b", "c"],
|
|
103
|
+
* Arr.mapWithIndex((i, s) => ({ position: i + 1, value: s }))
|
|
104
|
+
* ); // [{ position: 1, value: "a" }, { position: 2, value: "b" }, { position: 3, value: "c" }]
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (data: readonly A[]) => readonly B[];
|
|
96
108
|
/**
|
|
97
109
|
* Filters elements that satisfy the predicate.
|
|
98
110
|
*
|
|
@@ -855,6 +867,66 @@ declare namespace Num {
|
|
|
855
867
|
* ```
|
|
856
868
|
*/
|
|
857
869
|
const divide: (b: number) => (a: number) => number;
|
|
870
|
+
/**
|
|
871
|
+
* Returns the absolute value of a number.
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```ts
|
|
875
|
+
* pipe(-5, Num.abs); // 5
|
|
876
|
+
* pipe(5, Num.abs); // 5
|
|
877
|
+
* ```
|
|
878
|
+
*/
|
|
879
|
+
const abs: (n: number) => number;
|
|
880
|
+
/**
|
|
881
|
+
* Negates a number (arithmetic negation).
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* ```ts
|
|
885
|
+
* pipe(5, Num.negate); // -5
|
|
886
|
+
* pipe(-5, Num.negate); // 5
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
const negate: (n: number) => number;
|
|
890
|
+
/**
|
|
891
|
+
* Rounds a number to the nearest integer.
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```ts
|
|
895
|
+
* pipe(3.5, Num.round); // 4
|
|
896
|
+
* pipe(3.4, Num.round); // 3
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
const round: (n: number) => number;
|
|
900
|
+
/**
|
|
901
|
+
* Rounds a number down to the nearest integer.
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* ```ts
|
|
905
|
+
* pipe(3.9, Num.floor); // 3
|
|
906
|
+
* pipe(-3.2, Num.floor); // -4
|
|
907
|
+
* ```
|
|
908
|
+
*/
|
|
909
|
+
const floor: (n: number) => number;
|
|
910
|
+
/**
|
|
911
|
+
* Rounds a number up to the nearest integer.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* pipe(3.1, Num.ceil); // 4
|
|
916
|
+
* pipe(-3.9, Num.ceil); // -3
|
|
917
|
+
* ```
|
|
918
|
+
*/
|
|
919
|
+
const ceil: (n: number) => number;
|
|
920
|
+
/**
|
|
921
|
+
* Returns the remainder of dividing a number by `divisor`. Data-last: `remainder(divisor)(a)` = `a % divisor`.
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```ts
|
|
925
|
+
* pipe(10, Num.remainder(3)); // 1
|
|
926
|
+
* pipe([10, 11, 12], Arr.map(Num.remainder(3))); // [1, 2, 0]
|
|
927
|
+
* ```
|
|
928
|
+
*/
|
|
929
|
+
const remainder: (divisor: number) => (n: number) => number;
|
|
858
930
|
}
|
|
859
931
|
|
|
860
932
|
/**
|
|
@@ -1133,6 +1205,66 @@ declare namespace Str {
|
|
|
1133
1205
|
* ```
|
|
1134
1206
|
*/
|
|
1135
1207
|
const words: (s: string) => readonly string[];
|
|
1208
|
+
/**
|
|
1209
|
+
* Returns `true` when the string is empty.
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* ```ts
|
|
1213
|
+
* pipe("", Str.isEmpty); // true
|
|
1214
|
+
* pipe("hi", Str.isEmpty); // false
|
|
1215
|
+
* ```
|
|
1216
|
+
*/
|
|
1217
|
+
const isEmpty: (s: string) => boolean;
|
|
1218
|
+
/**
|
|
1219
|
+
* Returns `true` when the string is empty or contains only whitespace.
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```ts
|
|
1223
|
+
* pipe(" ", Str.isBlank); // true
|
|
1224
|
+
* pipe("hi", Str.isBlank); // false
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
const isBlank: (s: string) => boolean;
|
|
1228
|
+
/**
|
|
1229
|
+
* Returns the length of the string.
|
|
1230
|
+
*
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```ts
|
|
1233
|
+
* pipe("hello", Str.length); // 5
|
|
1234
|
+
* pipe("", Str.length); // 0
|
|
1235
|
+
* ```
|
|
1236
|
+
*/
|
|
1237
|
+
const length: (s: string) => number;
|
|
1238
|
+
/**
|
|
1239
|
+
* Extracts a substring between two indices. Data-last: use in `pipe`.
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```ts
|
|
1243
|
+
* pipe("hello", Str.slice(1, 3)); // "el"
|
|
1244
|
+
* pipe("hello", Str.slice(2)); // "llo"
|
|
1245
|
+
* ```
|
|
1246
|
+
*/
|
|
1247
|
+
const slice: (start: number, end?: number) => (s: string) => string;
|
|
1248
|
+
/**
|
|
1249
|
+
* Pads the start of a string to a specified length. Data-last: use in `pipe`.
|
|
1250
|
+
*
|
|
1251
|
+
* @example
|
|
1252
|
+
* ```ts
|
|
1253
|
+
* pipe("5", Str.padStart(3, "0")); // "005"
|
|
1254
|
+
* pipe("hi", Str.padStart(5)); // " hi"
|
|
1255
|
+
* ```
|
|
1256
|
+
*/
|
|
1257
|
+
const padStart: (maxLength: number, fillString?: string) => (s: string) => string;
|
|
1258
|
+
/**
|
|
1259
|
+
* Pads the end of a string to a specified length. Data-last: use in `pipe`.
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```ts
|
|
1263
|
+
* pipe("hi", Str.padEnd(5, ".")); // "hi..."
|
|
1264
|
+
* pipe("hi", Str.padEnd(5)); // "hi "
|
|
1265
|
+
* ```
|
|
1266
|
+
*/
|
|
1267
|
+
const padEnd: (maxLength: number, fillString?: string) => (s: string) => string;
|
|
1136
1268
|
/**
|
|
1137
1269
|
* Safe number parsers that return `Maybe` instead of `NaN`.
|
|
1138
1270
|
*/
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Maybe, R as Result, T as Task } from './Task-
|
|
1
|
+
import { M as Maybe, R as Result, T as Task } from './Task-C8Pgm7EX.js';
|
|
2
2
|
import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -93,6 +93,18 @@ declare namespace Arr {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
const map: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly B[];
|
|
96
|
+
/**
|
|
97
|
+
* Transforms each element using both its value and its zero-based index.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* pipe(
|
|
102
|
+
* ["a", "b", "c"],
|
|
103
|
+
* Arr.mapWithIndex((i, s) => ({ position: i + 1, value: s }))
|
|
104
|
+
* ); // [{ position: 1, value: "a" }, { position: 2, value: "b" }, { position: 3, value: "c" }]
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (data: readonly A[]) => readonly B[];
|
|
96
108
|
/**
|
|
97
109
|
* Filters elements that satisfy the predicate.
|
|
98
110
|
*
|
|
@@ -855,6 +867,66 @@ declare namespace Num {
|
|
|
855
867
|
* ```
|
|
856
868
|
*/
|
|
857
869
|
const divide: (b: number) => (a: number) => number;
|
|
870
|
+
/**
|
|
871
|
+
* Returns the absolute value of a number.
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```ts
|
|
875
|
+
* pipe(-5, Num.abs); // 5
|
|
876
|
+
* pipe(5, Num.abs); // 5
|
|
877
|
+
* ```
|
|
878
|
+
*/
|
|
879
|
+
const abs: (n: number) => number;
|
|
880
|
+
/**
|
|
881
|
+
* Negates a number (arithmetic negation).
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* ```ts
|
|
885
|
+
* pipe(5, Num.negate); // -5
|
|
886
|
+
* pipe(-5, Num.negate); // 5
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
const negate: (n: number) => number;
|
|
890
|
+
/**
|
|
891
|
+
* Rounds a number to the nearest integer.
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```ts
|
|
895
|
+
* pipe(3.5, Num.round); // 4
|
|
896
|
+
* pipe(3.4, Num.round); // 3
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
const round: (n: number) => number;
|
|
900
|
+
/**
|
|
901
|
+
* Rounds a number down to the nearest integer.
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* ```ts
|
|
905
|
+
* pipe(3.9, Num.floor); // 3
|
|
906
|
+
* pipe(-3.2, Num.floor); // -4
|
|
907
|
+
* ```
|
|
908
|
+
*/
|
|
909
|
+
const floor: (n: number) => number;
|
|
910
|
+
/**
|
|
911
|
+
* Rounds a number up to the nearest integer.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* pipe(3.1, Num.ceil); // 4
|
|
916
|
+
* pipe(-3.9, Num.ceil); // -3
|
|
917
|
+
* ```
|
|
918
|
+
*/
|
|
919
|
+
const ceil: (n: number) => number;
|
|
920
|
+
/**
|
|
921
|
+
* Returns the remainder of dividing a number by `divisor`. Data-last: `remainder(divisor)(a)` = `a % divisor`.
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```ts
|
|
925
|
+
* pipe(10, Num.remainder(3)); // 1
|
|
926
|
+
* pipe([10, 11, 12], Arr.map(Num.remainder(3))); // [1, 2, 0]
|
|
927
|
+
* ```
|
|
928
|
+
*/
|
|
929
|
+
const remainder: (divisor: number) => (n: number) => number;
|
|
858
930
|
}
|
|
859
931
|
|
|
860
932
|
/**
|
|
@@ -1133,6 +1205,66 @@ declare namespace Str {
|
|
|
1133
1205
|
* ```
|
|
1134
1206
|
*/
|
|
1135
1207
|
const words: (s: string) => readonly string[];
|
|
1208
|
+
/**
|
|
1209
|
+
* Returns `true` when the string is empty.
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* ```ts
|
|
1213
|
+
* pipe("", Str.isEmpty); // true
|
|
1214
|
+
* pipe("hi", Str.isEmpty); // false
|
|
1215
|
+
* ```
|
|
1216
|
+
*/
|
|
1217
|
+
const isEmpty: (s: string) => boolean;
|
|
1218
|
+
/**
|
|
1219
|
+
* Returns `true` when the string is empty or contains only whitespace.
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```ts
|
|
1223
|
+
* pipe(" ", Str.isBlank); // true
|
|
1224
|
+
* pipe("hi", Str.isBlank); // false
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
const isBlank: (s: string) => boolean;
|
|
1228
|
+
/**
|
|
1229
|
+
* Returns the length of the string.
|
|
1230
|
+
*
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```ts
|
|
1233
|
+
* pipe("hello", Str.length); // 5
|
|
1234
|
+
* pipe("", Str.length); // 0
|
|
1235
|
+
* ```
|
|
1236
|
+
*/
|
|
1237
|
+
const length: (s: string) => number;
|
|
1238
|
+
/**
|
|
1239
|
+
* Extracts a substring between two indices. Data-last: use in `pipe`.
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```ts
|
|
1243
|
+
* pipe("hello", Str.slice(1, 3)); // "el"
|
|
1244
|
+
* pipe("hello", Str.slice(2)); // "llo"
|
|
1245
|
+
* ```
|
|
1246
|
+
*/
|
|
1247
|
+
const slice: (start: number, end?: number) => (s: string) => string;
|
|
1248
|
+
/**
|
|
1249
|
+
* Pads the start of a string to a specified length. Data-last: use in `pipe`.
|
|
1250
|
+
*
|
|
1251
|
+
* @example
|
|
1252
|
+
* ```ts
|
|
1253
|
+
* pipe("5", Str.padStart(3, "0")); // "005"
|
|
1254
|
+
* pipe("hi", Str.padStart(5)); // " hi"
|
|
1255
|
+
* ```
|
|
1256
|
+
*/
|
|
1257
|
+
const padStart: (maxLength: number, fillString?: string) => (s: string) => string;
|
|
1258
|
+
/**
|
|
1259
|
+
* Pads the end of a string to a specified length. Data-last: use in `pipe`.
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```ts
|
|
1263
|
+
* pipe("hi", Str.padEnd(5, ".")); // "hi..."
|
|
1264
|
+
* pipe("hi", Str.padEnd(5)); // "hi "
|
|
1265
|
+
* ```
|
|
1266
|
+
*/
|
|
1267
|
+
const padEnd: (maxLength: number, fillString?: string) => (s: string) => string;
|
|
1136
1268
|
/**
|
|
1137
1269
|
* Safe number parsers that return `Maybe` instead of `NaN`.
|
|
1138
1270
|
*/
|
package/dist/utils.js
CHANGED
|
@@ -67,6 +67,7 @@ var Result;
|
|
|
67
67
|
if ((0, Result2.isErr)(data)) f(data.error);
|
|
68
68
|
return data;
|
|
69
69
|
};
|
|
70
|
+
Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
|
|
70
71
|
Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
|
|
71
72
|
Result2.recoverUnless = (blockedErr, fallback) => (data) => (0, Result2.isErr)(data) && data.error !== blockedErr ? fallback() : data;
|
|
72
73
|
Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
|
|
@@ -108,6 +109,7 @@ var Task;
|
|
|
108
109
|
((Task2) => {
|
|
109
110
|
Task2.resolve = (value) => () => Deferred.fromPromise(Promise.resolve(value));
|
|
110
111
|
Task2.from = (f) => (signal) => Deferred.fromPromise(f(signal));
|
|
112
|
+
Task2.fromSync = (f) => () => Deferred.fromPromise(Promise.resolve(f()));
|
|
111
113
|
Task2.map = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then(f));
|
|
112
114
|
Task2.chain = (f) => (data) => (0, Task2.from)((signal) => toPromise(data, signal).then((a) => toPromise(f(a), signal)));
|
|
113
115
|
Task2.ap = (arg) => (data) => (0, Task2.from)(
|
|
@@ -228,6 +230,12 @@ var Arr;
|
|
|
228
230
|
for (let i = 0; i < n; i++) result[i] = f(data[i]);
|
|
229
231
|
return result;
|
|
230
232
|
};
|
|
233
|
+
Arr2.mapWithIndex = (f) => (data) => {
|
|
234
|
+
const n = data.length;
|
|
235
|
+
const result = new Array(n);
|
|
236
|
+
for (let i = 0; i < n; i++) result[i] = f(i, data[i]);
|
|
237
|
+
return result;
|
|
238
|
+
};
|
|
231
239
|
Arr2.filter = (predicate) => (data) => {
|
|
232
240
|
const n = data.length;
|
|
233
241
|
const result = [];
|
|
@@ -555,6 +563,12 @@ var Num;
|
|
|
555
563
|
Num2.subtract = (b) => (a) => a - b;
|
|
556
564
|
Num2.multiply = (b) => (a) => a * b;
|
|
557
565
|
Num2.divide = (b) => (a) => a / b;
|
|
566
|
+
Num2.abs = (n) => Math.abs(n);
|
|
567
|
+
Num2.negate = (n) => -n;
|
|
568
|
+
Num2.round = (n) => Math.round(n);
|
|
569
|
+
Num2.floor = (n) => Math.floor(n);
|
|
570
|
+
Num2.ceil = (n) => Math.ceil(n);
|
|
571
|
+
Num2.remainder = (divisor) => (n) => n % divisor;
|
|
558
572
|
})(Num || (Num = {}));
|
|
559
573
|
|
|
560
574
|
// src/Utils/Rec.ts
|
|
@@ -680,6 +694,12 @@ var Str;
|
|
|
680
694
|
Str2.toLowerCase = (s) => s.toLowerCase();
|
|
681
695
|
Str2.lines = (s) => s.split(/\r?\n|\r/);
|
|
682
696
|
Str2.words = (s) => s.trim().split(/\s+/).filter(Boolean);
|
|
697
|
+
Str2.isEmpty = (s) => s.length === 0;
|
|
698
|
+
Str2.isBlank = (s) => s.trim().length === 0;
|
|
699
|
+
Str2.length = (s) => s.length;
|
|
700
|
+
Str2.slice = (start, end) => (s) => s.slice(start, end);
|
|
701
|
+
Str2.padStart = (maxLength, fillString) => (s) => s.padStart(maxLength, fillString);
|
|
702
|
+
Str2.padEnd = (maxLength, fillString) => (s) => s.padEnd(maxLength, fillString);
|
|
683
703
|
Str2.parse = {
|
|
684
704
|
/**
|
|
685
705
|
* Parses a string as an integer (base 10). Returns `None` if the result is `NaN`.
|
package/dist/utils.mjs
CHANGED