@zelgadis87/utils-core 5.1.2 → 5.1.4
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/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/arrays.d.ts +1 -0
- package/dist/utils/nulls.d.ts +3 -2
- package/dist/utils/records.d.ts +1 -0
- package/dist/utils/strings.d.ts +3 -0
- package/esbuild/index.cjs +41 -2
- package/esbuild/index.cjs.map +2 -2
- package/esbuild/index.mjs +37 -2
- package/esbuild/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/utils/arrays.ts +9 -0
- package/src/utils/nulls.ts +6 -2
- package/src/utils/records.ts +10 -0
- package/src/utils/strings.ts +14 -3
package/esbuild/index.mjs
CHANGED
|
@@ -351,6 +351,11 @@ function ifNullOrUndefined(source, callback) {
|
|
|
351
351
|
if (isNullOrUndefined(source))
|
|
352
352
|
callback();
|
|
353
353
|
}
|
|
354
|
+
function throwIfNullOrUndefined(source, errorProducer = () => new Error(`Unexpected ${source} value`)) {
|
|
355
|
+
return ifNullOrUndefined(source, () => {
|
|
356
|
+
throw errorProducer();
|
|
357
|
+
});
|
|
358
|
+
}
|
|
354
359
|
|
|
355
360
|
// src/utils/arrays/groupBy.ts
|
|
356
361
|
function groupByString(arr, field) {
|
|
@@ -663,6 +668,14 @@ function sumArrayBy(arr, mapFn) {
|
|
|
663
668
|
return sum2 + value;
|
|
664
669
|
}, 0);
|
|
665
670
|
}
|
|
671
|
+
function shallowArrayEquals(a, b) {
|
|
672
|
+
if (a === b) return true;
|
|
673
|
+
if (a.length !== b.length) return false;
|
|
674
|
+
for (let i = 0; i < a.length; i++) {
|
|
675
|
+
if (a[i] !== b[i]) return false;
|
|
676
|
+
}
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
666
679
|
|
|
667
680
|
// src/utils/booleans.ts
|
|
668
681
|
function isTrue(x) {
|
|
@@ -951,6 +964,15 @@ function pick(o, keys) {
|
|
|
951
964
|
return obj;
|
|
952
965
|
}, {});
|
|
953
966
|
}
|
|
967
|
+
function shallowRecordEquals(a, b) {
|
|
968
|
+
if (a === b) return true;
|
|
969
|
+
const aKeys = Object.keys(a), bKeys = Object.keys(b);
|
|
970
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
971
|
+
for (const key of aKeys) {
|
|
972
|
+
if (a[key] !== b[key]) return false;
|
|
973
|
+
}
|
|
974
|
+
return true;
|
|
975
|
+
}
|
|
954
976
|
|
|
955
977
|
// src/utils/strings/StringParts.ts
|
|
956
978
|
var StringParts = class _StringParts {
|
|
@@ -1103,8 +1125,17 @@ function pluralize(n, singular, plural) {
|
|
|
1103
1125
|
}
|
|
1104
1126
|
return plural;
|
|
1105
1127
|
}
|
|
1106
|
-
function
|
|
1107
|
-
return
|
|
1128
|
+
function isNullOrUndefinedOrEmpty(source) {
|
|
1129
|
+
return isNullOrUndefined(source) || source.length === 0;
|
|
1130
|
+
}
|
|
1131
|
+
function wrapWithString(str, start, end = start) {
|
|
1132
|
+
if (isNullOrUndefinedOrEmpty(str))
|
|
1133
|
+
throw new Error(`Expected string to be non-empty, got: "${str}"`);
|
|
1134
|
+
if (isNullOrUndefinedOrEmpty(start))
|
|
1135
|
+
throw new Error(`Expected start delimiter to be non-empty, got: "${start}"`);
|
|
1136
|
+
if (isNullOrUndefinedOrEmpty(end))
|
|
1137
|
+
throw new Error(`Expected end delimiter to be non-empty, got: "${end}"`);
|
|
1138
|
+
return start + str + end;
|
|
1108
1139
|
}
|
|
1109
1140
|
|
|
1110
1141
|
// src/lazy/Lazy.ts
|
|
@@ -2794,6 +2825,7 @@ export {
|
|
|
2794
2825
|
isFunction,
|
|
2795
2826
|
isNegativeNumber,
|
|
2796
2827
|
isNullOrUndefined,
|
|
2828
|
+
isNullOrUndefinedOrEmpty,
|
|
2797
2829
|
isNumber,
|
|
2798
2830
|
isPositiveNumber,
|
|
2799
2831
|
isTimeInstant,
|
|
@@ -2836,6 +2868,8 @@ export {
|
|
|
2836
2868
|
roundToNearest,
|
|
2837
2869
|
roundToUpper,
|
|
2838
2870
|
roundTowardsZero,
|
|
2871
|
+
shallowArrayEquals,
|
|
2872
|
+
shallowRecordEquals,
|
|
2839
2873
|
sortedArray,
|
|
2840
2874
|
splitWords,
|
|
2841
2875
|
stringToNumber,
|
|
@@ -2844,6 +2878,7 @@ export {
|
|
|
2844
2878
|
sumBy,
|
|
2845
2879
|
tail,
|
|
2846
2880
|
throttle,
|
|
2881
|
+
throwIfNullOrUndefined,
|
|
2847
2882
|
transformCssDictionary,
|
|
2848
2883
|
tryToParseJson,
|
|
2849
2884
|
tryToParseNumber,
|