@zelgadis87/utils-core 5.1.1 → 5.1.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/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) {
@@ -937,7 +950,7 @@ function entriesToEntries(dict, mapper) {
937
950
  return entriesToDict(dictToEntries(dict).map((entry) => mapper(entry)));
938
951
  }
939
952
  var mapEntries = entriesToEntries;
940
- function mapEntriesToList(dict, mapper) {
953
+ function entriesToList(dict, mapper) {
941
954
  return dictToEntries(dict).map((entry) => mapper(entry));
942
955
  }
943
956
 
@@ -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,8 @@ function pluralize(n, singular, plural) {
1103
1125
  }
1104
1126
  return plural;
1105
1127
  }
1106
- function wrapWithString(str, delimiter) {
1107
- return delimiter + str + delimiter;
1128
+ function isNullOrUndefinedOrEmpty(source) {
1129
+ return isNullOrUndefined(source) || source.length === 0;
1108
1130
  }
1109
1131
 
1110
1132
  // src/lazy/Lazy.ts
@@ -2752,6 +2774,7 @@ export {
2752
2774
  ensureReadableArray,
2753
2775
  entriesToDict,
2754
2776
  entriesToEntries,
2777
+ entriesToList,
2755
2778
  extendArray,
2756
2779
  extendArrayWith,
2757
2780
  fill,
@@ -2793,6 +2816,7 @@ export {
2793
2816
  isFunction,
2794
2817
  isNegativeNumber,
2795
2818
  isNullOrUndefined,
2819
+ isNullOrUndefinedOrEmpty,
2796
2820
  isNumber,
2797
2821
  isPositiveNumber,
2798
2822
  isTimeInstant,
@@ -2804,7 +2828,6 @@ export {
2804
2828
  listToDict,
2805
2829
  mapDefined,
2806
2830
  mapEntries,
2807
- mapEntriesToList,
2808
2831
  mapFirstTruthy,
2809
2832
  mapTruthys,
2810
2833
  max,
@@ -2836,6 +2859,8 @@ export {
2836
2859
  roundToNearest,
2837
2860
  roundToUpper,
2838
2861
  roundTowardsZero,
2862
+ shallowArrayEquals,
2863
+ shallowRecordEquals,
2839
2864
  sortedArray,
2840
2865
  splitWords,
2841
2866
  stringToNumber,
@@ -2844,6 +2869,7 @@ export {
2844
2869
  sumBy,
2845
2870
  tail,
2846
2871
  throttle,
2872
+ throwIfNullOrUndefined,
2847
2873
  transformCssDictionary,
2848
2874
  tryToParseJson,
2849
2875
  tryToParseNumber,
@@ -2853,7 +2879,6 @@ export {
2853
2879
  upsert,
2854
2880
  withTryCatch,
2855
2881
  withTryCatchAsync,
2856
- wrapWithString,
2857
2882
  xor
2858
2883
  };
2859
2884
  //# sourceMappingURL=index.mjs.map