@zelgadis87/utils-core 5.0.1 → 5.0.3
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/time/TimeBase.d.ts +25 -14
- package/dist/time/TimeDuration.d.ts +4 -2
- package/dist/time/TimeInstant.d.ts +1 -1
- package/dist/time/TimeUnit.d.ts +1 -3
- package/dist/time/_index.d.ts +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/functions/_index.d.ts +3 -0
- package/dist/utils/functions/predicateBuilder.d.ts +7 -0
- package/dist/utils/functions.d.ts +1 -2
- package/dist/utils/records.d.ts +10 -0
- package/esbuild/index.cjs +100 -67
- package/esbuild/index.cjs.map +4 -4
- package/esbuild/index.mjs +87 -57
- package/esbuild/index.mjs.map +3 -3
- package/package.json +7 -7
- package/src/time/RandomTimeDuration.ts +1 -1
- package/src/time/TimeBase.ts +32 -8
- package/src/time/TimeDuration.ts +11 -3
- package/src/time/TimeInstant.ts +1 -1
- package/src/time/TimeUnit.ts +1 -6
- package/src/time/_index.ts +3 -2
- package/src/utils/errors.ts +13 -0
- package/src/utils/functions/_index.ts +4 -0
- package/src/utils/functions/predicateBuilder.ts +25 -0
- package/src/utils/functions.ts +2 -5
- package/src/utils/records.ts +10 -0
package/esbuild/index.cjs
CHANGED
|
@@ -32,12 +32,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
|
|
33
33
|
// ../../node_modules/.pnpm/small-date@2.0.1/node_modules/small-date/lib/format.js
|
|
34
34
|
var require_format = __commonJS({
|
|
35
|
-
"../../node_modules/.pnpm/small-date@2.0.1/node_modules/small-date/lib/format.js"(
|
|
35
|
+
"../../node_modules/.pnpm/small-date@2.0.1/node_modules/small-date/lib/format.js"(exports2) {
|
|
36
36
|
"use strict";
|
|
37
|
-
Object.defineProperty(
|
|
37
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
38
38
|
value: true
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
exports2["default"] = format2;
|
|
41
41
|
function ownKeys(object, enumerableOnly) {
|
|
42
42
|
var keys = Object.keys(object);
|
|
43
43
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -153,24 +153,24 @@ var require_format = __commonJS({
|
|
|
153
153
|
|
|
154
154
|
// ../../node_modules/.pnpm/small-date@2.0.1/node_modules/small-date/lib/index.js
|
|
155
155
|
var require_lib = __commonJS({
|
|
156
|
-
"../../node_modules/.pnpm/small-date@2.0.1/node_modules/small-date/lib/index.js"(
|
|
156
|
+
"../../node_modules/.pnpm/small-date@2.0.1/node_modules/small-date/lib/index.js"(exports2) {
|
|
157
157
|
"use strict";
|
|
158
|
-
Object.defineProperty(
|
|
158
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
159
159
|
value: true
|
|
160
160
|
});
|
|
161
|
-
|
|
161
|
+
exports2.format = void 0;
|
|
162
162
|
var _format = require_format();
|
|
163
163
|
var _format2 = _interopRequireDefault(_format);
|
|
164
164
|
function _interopRequireDefault(obj) {
|
|
165
165
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
exports2.format = _format2["default"];
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
// src/index.ts
|
|
172
|
-
var
|
|
173
|
-
__export(
|
|
172
|
+
var index_exports = {};
|
|
173
|
+
__export(index_exports, {
|
|
174
174
|
DataUpgrader: () => DataUpgrader,
|
|
175
175
|
Deferred: () => Deferred,
|
|
176
176
|
DeferredCanceledError: () => DeferredCanceledError,
|
|
@@ -183,6 +183,7 @@ __export(src_exports, {
|
|
|
183
183
|
Logger: () => Logger,
|
|
184
184
|
NEVER: () => NEVER,
|
|
185
185
|
Optional: () => Optional,
|
|
186
|
+
PredicateBuilder: () => PredicateBuilder,
|
|
186
187
|
RandomTimeDuration: () => RandomTimeDuration,
|
|
187
188
|
RateThrottler: () => RateThrottler,
|
|
188
189
|
Semaphore: () => Semaphore,
|
|
@@ -235,6 +236,8 @@ __export(src_exports, {
|
|
|
235
236
|
filterWithTypePredicate: () => filterWithTypePredicate,
|
|
236
237
|
first: () => first,
|
|
237
238
|
flatMapTruthys: () => flatMapTruthys,
|
|
239
|
+
getMessageFromError: () => getMessageFromError,
|
|
240
|
+
getStackFromError: () => getStackFromError,
|
|
238
241
|
groupByBoolean: () => groupByBoolean,
|
|
239
242
|
groupByBooleanWith: () => groupByBooleanWith,
|
|
240
243
|
groupByNumber: () => groupByNumber,
|
|
@@ -327,7 +330,7 @@ __export(src_exports, {
|
|
|
327
330
|
wrapWithString: () => wrapWithString,
|
|
328
331
|
xor: () => xor
|
|
329
332
|
});
|
|
330
|
-
module.exports = __toCommonJS(
|
|
333
|
+
module.exports = __toCommonJS(index_exports);
|
|
331
334
|
|
|
332
335
|
// src/async/Deferred.ts
|
|
333
336
|
var DeferredCanceledError = class extends Error {
|
|
@@ -430,8 +433,7 @@ var RateThrottler = class {
|
|
|
430
433
|
return slot.promise().then(() => fn());
|
|
431
434
|
} finally {
|
|
432
435
|
this._availableSlots.push(TimeInstant.now().addDuration(this.cooldown));
|
|
433
|
-
if (this._waitingRequests.length > 0)
|
|
434
|
-
this._waitingRequests.shift().resolve();
|
|
436
|
+
if (this._waitingRequests.length > 0) this._waitingRequests.shift().resolve();
|
|
435
437
|
}
|
|
436
438
|
};
|
|
437
439
|
if (this._availableSlots.length > 0) {
|
|
@@ -597,16 +599,14 @@ function sumBy(arr, getter) {
|
|
|
597
599
|
return sum(arr.map(getter));
|
|
598
600
|
}
|
|
599
601
|
function min(arr) {
|
|
600
|
-
if (arr.length === 0)
|
|
601
|
-
throw new Error("Cannot calculate value on empty array");
|
|
602
|
+
if (arr.length === 0) throw new Error("Cannot calculate value on empty array");
|
|
602
603
|
return arr.reduce((min2, cur) => cur < min2 ? cur : min2);
|
|
603
604
|
}
|
|
604
605
|
function minBy(arr, getter) {
|
|
605
606
|
return min(arr.map(getter));
|
|
606
607
|
}
|
|
607
608
|
function max(arr) {
|
|
608
|
-
if (arr.length === 0)
|
|
609
|
-
throw new Error("Cannot calculate value on empty array");
|
|
609
|
+
if (arr.length === 0) throw new Error("Cannot calculate value on empty array");
|
|
610
610
|
return arr.reduce((max2, cur) => cur > max2 ? cur : max2);
|
|
611
611
|
}
|
|
612
612
|
function maxBy(arr, getter) {
|
|
@@ -646,6 +646,25 @@ function iff(firstPredicate, valueIfTrue) {
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
// src/utils/functions/predicateBuilder.ts
|
|
650
|
+
var PredicateBuilder = class {
|
|
651
|
+
_currentPredicate = constantTrue;
|
|
652
|
+
and(predicate) {
|
|
653
|
+
const curPredicate = this._currentPredicate.bind(void 0);
|
|
654
|
+
const newPredicate = (t) => curPredicate(t) && predicate(t);
|
|
655
|
+
this._currentPredicate = newPredicate;
|
|
656
|
+
return this;
|
|
657
|
+
}
|
|
658
|
+
or(predicate) {
|
|
659
|
+
const newPredicate = (t) => this._currentPredicate(t) || predicate(t);
|
|
660
|
+
this._currentPredicate = newPredicate;
|
|
661
|
+
return this;
|
|
662
|
+
}
|
|
663
|
+
toPredicate() {
|
|
664
|
+
return this._currentPredicate;
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
|
|
649
668
|
// src/utils/functions.ts
|
|
650
669
|
function isFunction(t) {
|
|
651
670
|
return typeof t === "function";
|
|
@@ -659,17 +678,13 @@ function not(predicate) {
|
|
|
659
678
|
return (t) => !predicate(t);
|
|
660
679
|
}
|
|
661
680
|
function and(...predicates) {
|
|
662
|
-
if (predicates.length === 0)
|
|
663
|
-
|
|
664
|
-
else if (predicates.length === 1)
|
|
665
|
-
return predicates[0];
|
|
681
|
+
if (predicates.length === 0) return constantTrue;
|
|
682
|
+
else if (predicates.length === 1) return predicates[0];
|
|
666
683
|
return (t) => predicates.reduce((prev, cur) => prev ? cur(t) : false, true);
|
|
667
684
|
}
|
|
668
685
|
function or(...predicates) {
|
|
669
|
-
if (predicates.length === 0)
|
|
670
|
-
|
|
671
|
-
else if (predicates.length === 1)
|
|
672
|
-
return predicates[0];
|
|
686
|
+
if (predicates.length === 0) return constantTrue;
|
|
687
|
+
else if (predicates.length === 1) return predicates[0];
|
|
673
688
|
return (t) => predicates.reduce((prev, cur) => prev ? true : cur(t), false);
|
|
674
689
|
}
|
|
675
690
|
function xor(a, b) {
|
|
@@ -713,13 +728,11 @@ function uniqByKey(arr, key) {
|
|
|
713
728
|
|
|
714
729
|
// src/utils/arrays.ts
|
|
715
730
|
function ensureArray(t) {
|
|
716
|
-
if (isNullOrUndefined(t))
|
|
717
|
-
return [];
|
|
731
|
+
if (isNullOrUndefined(t)) return [];
|
|
718
732
|
return t instanceof Array ? t : [t];
|
|
719
733
|
}
|
|
720
734
|
function ensureReadableArray(t) {
|
|
721
|
-
if (isNullOrUndefined(t))
|
|
722
|
-
return [];
|
|
735
|
+
if (isNullOrUndefined(t)) return [];
|
|
723
736
|
return t instanceof Array ? t : [t];
|
|
724
737
|
}
|
|
725
738
|
function isArray(t) {
|
|
@@ -738,8 +751,7 @@ function upsert(arr, item, isEqual) {
|
|
|
738
751
|
}
|
|
739
752
|
}
|
|
740
753
|
function range(start, end) {
|
|
741
|
-
if (end < start)
|
|
742
|
-
throw new Error();
|
|
754
|
+
if (end < start) throw new Error();
|
|
743
755
|
let length = end - start + 1;
|
|
744
756
|
return new Array(length).fill(1).map((_, i) => start + i);
|
|
745
757
|
}
|
|
@@ -798,8 +810,7 @@ function partition(arr, predicate) {
|
|
|
798
810
|
function mapFirstTruthy(arr, mapFn) {
|
|
799
811
|
for (let i = 0; i < arr.length; i++) {
|
|
800
812
|
const result = mapFn(arr[i]);
|
|
801
|
-
if (result)
|
|
802
|
-
return result;
|
|
813
|
+
if (result) return result;
|
|
803
814
|
}
|
|
804
815
|
return null;
|
|
805
816
|
}
|
|
@@ -827,8 +838,7 @@ function cssDeclarationRulesDictionaryToCss(syleDeclarationRulesForSelectorsProd
|
|
|
827
838
|
const syleDeclarationRulesForSelectors = produceableToValue(syleDeclarationRulesForSelectorsProduceable);
|
|
828
839
|
return Object.entries(syleDeclarationRulesForSelectors).map(([selector, styleDeclarationRules]) => {
|
|
829
840
|
const cssRules = cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules, indent + 1);
|
|
830
|
-
if (!cssRules.length)
|
|
831
|
-
return null;
|
|
841
|
+
if (!cssRules.length) return null;
|
|
832
842
|
return repeat(tabulation, indent) + selector + space + openBracket + newLine + cssRules.join(newLine) + newLine + closeBracket;
|
|
833
843
|
}).filter(Boolean).join(newLine + newLine);
|
|
834
844
|
}
|
|
@@ -896,14 +906,26 @@ function asError(e) {
|
|
|
896
906
|
function isError(e) {
|
|
897
907
|
return e instanceof Error;
|
|
898
908
|
}
|
|
909
|
+
function getMessageFromError(error) {
|
|
910
|
+
const maybeCause = error.cause ? getMessageFromError(asError(error.cause)) : null;
|
|
911
|
+
const cause = maybeCause ? `
|
|
912
|
+
caused by: ${maybeCause}` : "";
|
|
913
|
+
return `${error.name}: ${error.message}${cause}`;
|
|
914
|
+
}
|
|
915
|
+
function getStackFromError(error) {
|
|
916
|
+
const maybeCause = error.cause ? getStackFromError(asError(error.cause)) : null;
|
|
917
|
+
const cause = maybeCause ? `
|
|
918
|
+
caused by: ${maybeCause}` : "";
|
|
919
|
+
const stack = error.stack && error.stack.includes(error.message) ? error.stack : error.message + " " + (error.stack ?? "");
|
|
920
|
+
return `${error.name}: ${stack}${cause}`;
|
|
921
|
+
}
|
|
899
922
|
|
|
900
923
|
// src/utils/json.ts
|
|
901
924
|
function tryToParseJson(jsonContent) {
|
|
902
925
|
return withTryCatch(() => JSON.parse(jsonContent));
|
|
903
926
|
}
|
|
904
927
|
function jsonCloneDeep(a) {
|
|
905
|
-
if (null === a || "object" !== typeof a)
|
|
906
|
-
return a;
|
|
928
|
+
if (null === a || "object" !== typeof a) return a;
|
|
907
929
|
if (a instanceof Date) {
|
|
908
930
|
return new Date(a.getTime());
|
|
909
931
|
} else if (a instanceof Array) {
|
|
@@ -1010,13 +1032,10 @@ function clampInt0_100(n) {
|
|
|
1010
1032
|
function tryToParseNumber(numberStr) {
|
|
1011
1033
|
return withTryCatch(() => {
|
|
1012
1034
|
const type = typeof ensureDefined(numberStr);
|
|
1013
|
-
if (type !== "string")
|
|
1014
|
-
|
|
1015
|
-
if (numberStr.trim().length === 0)
|
|
1016
|
-
throw new Error("Invalid number given: " + numberStr);
|
|
1035
|
+
if (type !== "string") throw new Error("Invalid number given: " + numberStr);
|
|
1036
|
+
if (numberStr.trim().length === 0) throw new Error("Invalid number given: " + numberStr);
|
|
1017
1037
|
const num = Number(numberStr);
|
|
1018
|
-
if (isNaN(num))
|
|
1019
|
-
throw new Error("Invalid number given: " + numberStr);
|
|
1038
|
+
if (isNaN(num)) throw new Error("Invalid number given: " + numberStr);
|
|
1020
1039
|
return num;
|
|
1021
1040
|
});
|
|
1022
1041
|
}
|
|
@@ -1096,8 +1115,7 @@ var StringParts = class _StringParts {
|
|
|
1096
1115
|
return new _StringParts(...this.parts.map((part) => part.toLowerCase()));
|
|
1097
1116
|
}
|
|
1098
1117
|
capitalizeFirst() {
|
|
1099
|
-
if (!this.length)
|
|
1100
|
-
return this;
|
|
1118
|
+
if (!this.length) return this;
|
|
1101
1119
|
return new _StringParts(capitalizeWord(this.first), ...this.tail.map((part) => part.toLowerCase()));
|
|
1102
1120
|
}
|
|
1103
1121
|
capitalizeEach() {
|
|
@@ -1126,8 +1144,7 @@ var StringParts = class _StringParts {
|
|
|
1126
1144
|
return this.toLowerCase().join("_");
|
|
1127
1145
|
}
|
|
1128
1146
|
toCamelCase() {
|
|
1129
|
-
if (!this.length)
|
|
1130
|
-
return "";
|
|
1147
|
+
if (!this.length) return "";
|
|
1131
1148
|
return [this.first.toLowerCase(), ...this.tail.map(capitalizeWord)].join("");
|
|
1132
1149
|
}
|
|
1133
1150
|
toKebabCase() {
|
|
@@ -1201,8 +1218,7 @@ function stringToNumber(s) {
|
|
|
1201
1218
|
}
|
|
1202
1219
|
function pad(str, n, char, where = "left") {
|
|
1203
1220
|
const length = ensureDefined(str).length;
|
|
1204
|
-
if (length >= ensureDefined(n))
|
|
1205
|
-
return str;
|
|
1221
|
+
if (length >= ensureDefined(n)) return str;
|
|
1206
1222
|
if (ensureDefined(char).length !== 1)
|
|
1207
1223
|
throw new Error("Illegal pad character");
|
|
1208
1224
|
const padding = repeat(char, n - length);
|
|
@@ -1432,15 +1448,11 @@ var TimeUnit = class _TimeUnit {
|
|
|
1432
1448
|
toDays(value) {
|
|
1433
1449
|
return this.toUnit(value, _TimeUnit.DAYS);
|
|
1434
1450
|
}
|
|
1435
|
-
toWeeks(value) {
|
|
1436
|
-
return this.toUnit(value, _TimeUnit.WEEKS);
|
|
1437
|
-
}
|
|
1438
1451
|
static MILLISECONDS = new _TimeUnit(1);
|
|
1439
1452
|
static SECONDS = new _TimeUnit(1e3 * _TimeUnit.MILLISECONDS.multiplier);
|
|
1440
1453
|
static MINUTES = new _TimeUnit(60 * _TimeUnit.SECONDS.multiplier);
|
|
1441
1454
|
static HOURS = new _TimeUnit(60 * _TimeUnit.MINUTES.multiplier);
|
|
1442
1455
|
static DAYS = new _TimeUnit(24 * _TimeUnit.HOURS.multiplier);
|
|
1443
|
-
static WEEKS = new _TimeUnit(7 * _TimeUnit.DAYS.multiplier);
|
|
1444
1456
|
};
|
|
1445
1457
|
|
|
1446
1458
|
// src/time/TimeBase.ts
|
|
@@ -1449,18 +1461,33 @@ var TimeBase = class {
|
|
|
1449
1461
|
constructor(value, unit) {
|
|
1450
1462
|
this._ms = unit.toMs(value);
|
|
1451
1463
|
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Total number of milliseconds, rounded down.
|
|
1466
|
+
*/
|
|
1452
1467
|
get ms() {
|
|
1453
1468
|
return Math.floor(this._ms / TimeUnit.MILLISECONDS.multiplier);
|
|
1454
1469
|
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Total number of seconds, rounded down.
|
|
1472
|
+
*/
|
|
1455
1473
|
get seconds() {
|
|
1456
1474
|
return Math.floor(this._ms / TimeUnit.SECONDS.multiplier);
|
|
1457
1475
|
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Total number of minutes, rounded down.
|
|
1478
|
+
*/
|
|
1458
1479
|
get minutes() {
|
|
1459
1480
|
return Math.floor(this._ms / TimeUnit.MINUTES.multiplier);
|
|
1460
1481
|
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Total number of hours, rounded down.
|
|
1484
|
+
*/
|
|
1461
1485
|
get hours() {
|
|
1462
1486
|
return Math.floor(this._ms / TimeUnit.HOURS.multiplier);
|
|
1463
1487
|
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Total number of days, rounded down.
|
|
1490
|
+
*/
|
|
1464
1491
|
get days() {
|
|
1465
1492
|
return Math.floor(this._ms / TimeUnit.DAYS.multiplier);
|
|
1466
1493
|
}
|
|
@@ -1505,17 +1532,18 @@ var TimeBase = class {
|
|
|
1505
1532
|
}
|
|
1506
1533
|
toUnits() {
|
|
1507
1534
|
return {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
minutes: Math.floor(this.
|
|
1511
|
-
|
|
1535
|
+
milliseconds: this.ms % TimeUnit.SECONDS.multiplier,
|
|
1536
|
+
seconds: Math.floor(this.seconds % 60),
|
|
1537
|
+
minutes: Math.floor(this.minutes % 60),
|
|
1538
|
+
hours: Math.floor(this.hours % 24),
|
|
1539
|
+
days: Math.floor(this.days)
|
|
1512
1540
|
};
|
|
1513
1541
|
}
|
|
1514
|
-
static
|
|
1542
|
+
static unitsToMs(units) {
|
|
1515
1543
|
if (!units)
|
|
1516
1544
|
throw new Error("Invalid units given");
|
|
1517
1545
|
let ms = 0;
|
|
1518
|
-
ms += units.
|
|
1546
|
+
ms += (units.milliseconds ?? 0) * TimeUnit.MILLISECONDS.multiplier;
|
|
1519
1547
|
ms += (units.seconds ?? 0) * TimeUnit.SECONDS.multiplier;
|
|
1520
1548
|
ms += (units.minutes ?? 0) * TimeUnit.MINUTES.multiplier;
|
|
1521
1549
|
ms += (units.hours ?? 0) * TimeUnit.HOURS.multiplier;
|
|
@@ -1565,8 +1593,7 @@ var TimeDuration = class _TimeDuration extends TimeBase {
|
|
|
1565
1593
|
get formatted() {
|
|
1566
1594
|
const format2 = (x, u1, y, u2) => `${x}${u1} ${pad(y.toString(), 2, "0")}${u2}`;
|
|
1567
1595
|
const units = this.toUnits();
|
|
1568
|
-
if (units.days >= 1)
|
|
1569
|
-
return format2(units.days, "d", units.hours, "h");
|
|
1596
|
+
if (units.days >= 1) return format2(units.days, "d", units.hours, "h");
|
|
1570
1597
|
else if (units.hours >= 1)
|
|
1571
1598
|
return format2(units.hours, "h", units.minutes, "m");
|
|
1572
1599
|
else if (units.minutes >= 1)
|
|
@@ -1677,6 +1704,9 @@ var TimeDuration = class _TimeDuration extends TimeBase {
|
|
|
1677
1704
|
isNotEmpty() {
|
|
1678
1705
|
return this.ms > 0;
|
|
1679
1706
|
}
|
|
1707
|
+
toUnits() {
|
|
1708
|
+
return super.toUnits();
|
|
1709
|
+
}
|
|
1680
1710
|
/**
|
|
1681
1711
|
* This method is used to provide a better DX when inspecting a TimeInstant object in DevTools.
|
|
1682
1712
|
*/
|
|
@@ -1690,7 +1720,7 @@ var TimeDuration = class _TimeDuration extends TimeBase {
|
|
|
1690
1720
|
const match = humanTime.trim().match(/^(?:([0-9]+)d|)\s*(?:([0-9]+)h|)\s*(?:([0-9]+)m|)\s*(?:([0-9]+)s|)$/);
|
|
1691
1721
|
if (match) {
|
|
1692
1722
|
const [_, days, hours, minutes, seconds] = match;
|
|
1693
|
-
return new _TimeDuration(TimeBase.
|
|
1723
|
+
return new _TimeDuration(TimeBase.unitsToMs({ days: Number(days ?? 0), hours: Number(hours ?? 0), minutes: Number(minutes ?? 0), seconds: Number(seconds ?? 0) }), TimeUnit.MILLISECONDS);
|
|
1694
1724
|
}
|
|
1695
1725
|
throw new Error("Failed to parse time: " + humanTime);
|
|
1696
1726
|
}
|
|
@@ -1742,6 +1772,9 @@ var TimeDuration = class _TimeDuration extends TimeBase {
|
|
|
1742
1772
|
static fromJSON(ms) {
|
|
1743
1773
|
return _TimeDuration.ms(ms);
|
|
1744
1774
|
}
|
|
1775
|
+
static fromUnits(parameters) {
|
|
1776
|
+
return _TimeDuration.ms(TimeBase.unitsToMs(parameters));
|
|
1777
|
+
}
|
|
1745
1778
|
};
|
|
1746
1779
|
function isAllowedTimeDuration(t) {
|
|
1747
1780
|
return typeof t === "number" && t > 0 || t instanceof TimeDuration;
|
|
@@ -1819,8 +1852,7 @@ var getFromDate = {
|
|
|
1819
1852
|
};
|
|
1820
1853
|
var toReferenceDate = (x) => {
|
|
1821
1854
|
ensureDefined(x);
|
|
1822
|
-
if (isTimeInstant(x))
|
|
1823
|
-
return x.toDate();
|
|
1855
|
+
if (isTimeInstant(x)) return x.toDate();
|
|
1824
1856
|
return x;
|
|
1825
1857
|
};
|
|
1826
1858
|
function createTimeInstantFromParameters(aParameters, aReferenceDate = TimeInstant.now()) {
|
|
@@ -2255,8 +2287,7 @@ var Optional = class _Optional {
|
|
|
2255
2287
|
}
|
|
2256
2288
|
}
|
|
2257
2289
|
orElseNullable(newValue) {
|
|
2258
|
-
if (this.isEmpty())
|
|
2259
|
-
return _Optional.ofNullable(newValue);
|
|
2290
|
+
if (this.isEmpty()) return _Optional.ofNullable(newValue);
|
|
2260
2291
|
return this;
|
|
2261
2292
|
}
|
|
2262
2293
|
orElseGetNullable(newValueProducer) {
|
|
@@ -2386,8 +2417,7 @@ var prioritizeSet = (fns, transform, set, reversed = false) => {
|
|
|
2386
2417
|
var prioritizeArray = (fns, transform, arr, reversed = false) => {
|
|
2387
2418
|
return compareNumbers(fns, (t) => {
|
|
2388
2419
|
const r = transform(t);
|
|
2389
|
-
if (!isDefined(r))
|
|
2390
|
-
return Number.MAX_VALUE;
|
|
2420
|
+
if (!isDefined(r)) return Number.MAX_VALUE;
|
|
2391
2421
|
const indexOf = arr.indexOf(r);
|
|
2392
2422
|
return indexOf === -1 ? Number.MAX_VALUE : indexOf;
|
|
2393
2423
|
}, { direction: reversed ? "DESC" : "ASC", nullsFirst: false });
|
|
@@ -2782,6 +2812,7 @@ function isUpgradable(obj) {
|
|
|
2782
2812
|
Logger,
|
|
2783
2813
|
NEVER,
|
|
2784
2814
|
Optional,
|
|
2815
|
+
PredicateBuilder,
|
|
2785
2816
|
RandomTimeDuration,
|
|
2786
2817
|
RateThrottler,
|
|
2787
2818
|
Semaphore,
|
|
@@ -2834,6 +2865,8 @@ function isUpgradable(obj) {
|
|
|
2834
2865
|
filterWithTypePredicate,
|
|
2835
2866
|
first,
|
|
2836
2867
|
flatMapTruthys,
|
|
2868
|
+
getMessageFromError,
|
|
2869
|
+
getStackFromError,
|
|
2837
2870
|
groupByBoolean,
|
|
2838
2871
|
groupByBooleanWith,
|
|
2839
2872
|
groupByNumber,
|