@zelgadis87/utils-core 5.2.0 → 5.2.2

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
@@ -416,8 +416,12 @@ function indexBySymbolWith(arr, getter) {
416
416
  function doIndexByWith(arr, getter) {
417
417
  return arr.reduce((dict, cur) => {
418
418
  const key = getter(cur);
419
- if (key !== null && key !== void 0)
419
+ if (key !== null && key !== void 0) {
420
+ if (dict[key]) {
421
+ throw new Error(`Multiple values indexed by same key "${String(key)}".`);
422
+ }
420
423
  dict[key] = cur;
424
+ }
421
425
  return dict;
422
426
  }, {});
423
427
  }
@@ -770,24 +774,29 @@ function isError(e) {
770
774
  return e instanceof Error;
771
775
  }
772
776
  function getMessageFromError(error) {
773
- return `${error.name}: ${error.message}${getCauseMessageFromError(error.cause)}`;
777
+ return `${error.name}: ${error.message}${getCauseMessageFromError(error)}`;
774
778
  }
775
779
  function getStackFromError(error) {
776
780
  const stack = error.stack && error.stack.includes(error.message) ? error.stack : error.message + " " + (error.stack ?? "");
777
- return `${error.name}: ${stack}${getCauseStackFromError(error.cause)}`;
781
+ return `${error.name}: ${stack}${getCauseStackFromError(error)}`;
778
782
  }
779
- function getCauseMessageFromError(cause) {
780
- if (isNullOrUndefined(cause))
783
+ function getCauseMessageFromError(error) {
784
+ if (isNullOrUndefined(error.cause))
781
785
  return "";
782
786
  return `
783
- caused by: ${getMessageFromError(asError(cause))}`;
787
+ caused by: ${getMessageFromError(asError(error.cause))}`;
784
788
  }
785
- function getCauseStackFromError(cause) {
786
- if (isNullOrUndefined(cause))
789
+ function getCauseStackFromError(error) {
790
+ if (isNullOrUndefined(error.cause))
787
791
  return "";
788
792
  return `
789
- caused by: ${getStackFromError(asError(cause))}`;
793
+ caused by: ${getStackFromError(asError(error.cause))}`;
790
794
  }
795
+ var NonExhaustiveSwitchError = class extends Error {
796
+ constructor(value) {
797
+ super("Expected switch to be exhaustive, got: " + value);
798
+ }
799
+ };
791
800
 
792
801
  // src/utils/json.ts
793
802
  function tryToParseJson(jsonContent) {
@@ -2766,6 +2775,7 @@ export {
2766
2775
  LazyDictionary,
2767
2776
  Logger,
2768
2777
  NEVER,
2778
+ NonExhaustiveSwitchError,
2769
2779
  Optional,
2770
2780
  PredicateBuilder,
2771
2781
  RandomTimeDuration,