@zelgadis87/utils-core 5.1.5 → 5.2.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/esbuild/index.mjs CHANGED
@@ -770,17 +770,23 @@ function isError(e) {
770
770
  return e instanceof Error;
771
771
  }
772
772
  function getMessageFromError(error) {
773
- const maybeCause = error.cause ? getMessageFromError(asError(error.cause)) : null;
774
- const cause = maybeCause ? `
775
- caused by: ${maybeCause}` : "";
776
- return `${error.name}: ${error.message}${cause}`;
773
+ return `${error.name}: ${error.message}${getCauseMessageFromError(error.cause)}`;
777
774
  }
778
775
  function getStackFromError(error) {
779
- const maybeCause = error.cause ? getStackFromError(asError(error.cause)) : null;
780
- const cause = maybeCause ? `
781
- caused by: ${maybeCause}` : "";
782
776
  const stack = error.stack && error.stack.includes(error.message) ? error.stack : error.message + " " + (error.stack ?? "");
783
- return `${error.name}: ${stack}${cause}`;
777
+ return `${error.name}: ${stack}${getCauseStackFromError(error.cause)}`;
778
+ }
779
+ function getCauseMessageFromError(cause) {
780
+ if (isNullOrUndefined(cause))
781
+ return "";
782
+ return `
783
+ caused by: ${getMessageFromError(asError(cause))}`;
784
+ }
785
+ function getCauseStackFromError(cause) {
786
+ if (isNullOrUndefined(cause))
787
+ return "";
788
+ return `
789
+ caused by: ${getStackFromError(asError(cause))}`;
784
790
  }
785
791
 
786
792
  // src/utils/json.ts
@@ -791,7 +797,7 @@ function parseJson(jsonContent) {
791
797
  return JSON.parse(jsonContent);
792
798
  }
793
799
  function stringifyJson(jsonSerializable, minify = false) {
794
- return JSON.stringify(jsonSerializable, void 0, minify ? 2 : void 0);
800
+ return JSON.stringify(jsonSerializable, void 0, minify ? void 0 : 2);
795
801
  }
796
802
  function jsonCloneDeep(a) {
797
803
  if (null === a || "object" !== typeof a) return a;
@@ -1135,8 +1141,14 @@ function pluralize(n, singular, plural) {
1135
1141
  }
1136
1142
  return plural;
1137
1143
  }
1144
+ function isString(source) {
1145
+ return isDefined(source) && typeof source === "string";
1146
+ }
1147
+ function isEmpty(source) {
1148
+ return source.trim().length === 0;
1149
+ }
1138
1150
  function isNullOrUndefinedOrEmpty(source) {
1139
- return isNullOrUndefined(source) || source.length === 0;
1151
+ return isNullOrUndefined(source) || isEmpty(source);
1140
1152
  }
1141
1153
  function wrapWithString(str, start, end = start) {
1142
1154
  if (isNullOrUndefinedOrEmpty(str))
@@ -2078,7 +2090,7 @@ function isTimeInstant(x) {
2078
2090
  var TimeInstant_default = TimeInstant;
2079
2091
 
2080
2092
  // src/Logger.ts
2081
- var LEVELS = ["log", "debug", "info", "warn", "error"];
2093
+ var LEVELS = ["trace", "log", "debug", "info", "warn", "error"];
2082
2094
  var timestamp = () => TimeInstant_default.now().format("HH:mm:ss");
2083
2095
  var Logger = class {
2084
2096
  constructor(name, args) {
@@ -2090,6 +2102,9 @@ var Logger = class {
2090
2102
  enabled = true;
2091
2103
  console;
2092
2104
  minLevel;
2105
+ get trace() {
2106
+ return this.logWrap("trace");
2107
+ }
2093
2108
  get log() {
2094
2109
  return this.logWrap("log");
2095
2110
  }
@@ -2162,6 +2177,12 @@ var Optional = class _Optional {
2162
2177
  if (this.isPresent())
2163
2178
  callback(this.get());
2164
2179
  }
2180
+ ifPresentThenClear(callback) {
2181
+ if (this.isPresent()) {
2182
+ callback(this.get());
2183
+ this.clear();
2184
+ }
2185
+ }
2165
2186
  apply(callbackIfPresent, callbackIfEmpty) {
2166
2187
  if (this.isEmpty()) {
2167
2188
  callbackIfEmpty();
@@ -2802,6 +2823,8 @@ export {
2802
2823
  filterWithTypePredicate,
2803
2824
  first,
2804
2825
  flatMapTruthys,
2826
+ getCauseMessageFromError,
2827
+ getCauseStackFromError,
2805
2828
  getMessageFromError,
2806
2829
  getStackFromError,
2807
2830
  groupByBoolean,
@@ -2830,6 +2853,7 @@ export {
2830
2853
  isAllowedTimeDuration,
2831
2854
  isArray,
2832
2855
  isDefined,
2856
+ isEmpty,
2833
2857
  isError,
2834
2858
  isFalse,
2835
2859
  isFunction,
@@ -2838,6 +2862,7 @@ export {
2838
2862
  isNullOrUndefinedOrEmpty,
2839
2863
  isNumber,
2840
2864
  isPositiveNumber,
2865
+ isString,
2841
2866
  isTimeInstant,
2842
2867
  isTrue,
2843
2868
  isUpgradable,