@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/CHANGELOG.md +231 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/_index.d.ts +2 -1
- package/dist/utils/errors/withTryCatch.d.ts +3 -2
- package/dist/utils/errors.d.ts +15 -2
- package/dist/utils/numbers.d.ts +1 -1
- package/dist/utils/operations.d.ts +18 -0
- package/dist/utils/records.d.ts +21 -0
- package/esbuild/index.cjs +20 -9
- package/esbuild/index.cjs.map +2 -2
- package/esbuild/index.mjs +19 -9
- package/esbuild/index.mjs.map +2 -2
- package/package.json +8 -9
- package/src/utils/_index.ts +2 -1
- package/src/utils/arrays/indexBy.ts +5 -1
- package/src/utils/errors/withTryCatch.ts +3 -3
- package/src/utils/errors.ts +25 -8
- package/src/utils/operations.ts +24 -0
- package/src/utils/records.ts +20 -0
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
|
|
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
|
|
781
|
+
return `${error.name}: ${stack}${getCauseStackFromError(error)}`;
|
|
778
782
|
}
|
|
779
|
-
function getCauseMessageFromError(
|
|
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(
|
|
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,
|