@xylabs/error
Advanced tools
Comparing version
@@ -1,4 +0,3 @@ | ||
export * from './getFunctionName'; | ||
export * from './handleError'; | ||
export * from './isError'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -21,25 +21,3 @@ // src/isError.ts | ||
}; | ||
// src/getFunctionName.ts | ||
var getFunctionName = (depth = 2) => { | ||
try { | ||
throw Error(); | ||
} catch (ex) { | ||
return handleError(ex, (error) => { | ||
let newIndex = void 0; | ||
const stackParts = error.stack?.split("\n")[depth].split(" "); | ||
const funcName = stackParts?.find((item, index) => { | ||
if (item.length > 0 && item !== "at") { | ||
if (item === "new") { | ||
newIndex = index; | ||
} | ||
return item; | ||
} | ||
}) ?? "<unknown>"; | ||
return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName; | ||
}); | ||
} | ||
}; | ||
export { | ||
getFunctionName, | ||
handleError, | ||
@@ -46,0 +24,0 @@ handleErrorAsync, |
@@ -1,4 +0,3 @@ | ||
export * from './getFunctionName'; | ||
export * from './handleError'; | ||
export * from './isError'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,30 +0,1 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
getFunctionName: () => getFunctionName, | ||
handleError: () => handleError, | ||
handleErrorAsync: () => handleErrorAsync, | ||
isError: () => isError | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/isError.ts | ||
@@ -50,31 +21,7 @@ var isError = (error) => { | ||
}; | ||
// src/getFunctionName.ts | ||
var getFunctionName = (depth = 2) => { | ||
try { | ||
throw Error(); | ||
} catch (ex) { | ||
return handleError(ex, (error) => { | ||
var _a; | ||
let newIndex = void 0; | ||
const stackParts = (_a = error.stack) == null ? void 0 : _a.split("\n")[depth].split(" "); | ||
const funcName = (stackParts == null ? void 0 : stackParts.find((item, index) => { | ||
if (item.length > 0 && item !== "at") { | ||
if (item === "new") { | ||
newIndex = index; | ||
} | ||
return item; | ||
} | ||
})) ?? "<unknown>"; | ||
return newIndex ? `${funcName} ${stackParts == null ? void 0 : stackParts[newIndex + 1]}` : funcName; | ||
}); | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
getFunctionName, | ||
export { | ||
handleError, | ||
handleErrorAsync, | ||
isError | ||
}); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -34,8 +34,8 @@ { | ||
"require": { | ||
"types": "./dist/node/index.d.ts", | ||
"default": "./dist/node/index.js" | ||
"types": "./dist/node/index.d.cts", | ||
"default": "./dist/node/index.cjs" | ||
}, | ||
"import": { | ||
"types": "./dist/node/index.d.mts", | ||
"default": "./dist/node/index.mjs" | ||
"default": "./dist/node/index.js" | ||
} | ||
@@ -46,4 +46,5 @@ } | ||
}, | ||
"main": "dist/node/index.js", | ||
"module": "dist/node/index.mjs", | ||
"main": "dist/node/index.cjs", | ||
"module": "dist/node/index.js", | ||
"types": "dist/node/index.d.mts", | ||
"homepage": "https://xyo.network", | ||
@@ -59,4 +60,4 @@ "license": "LGPL-3.0-only", | ||
"sideEffects": false, | ||
"types": "dist/node/index.d.ts", | ||
"version": "2.13.5" | ||
"version": "2.13.7", | ||
"type": "module" | ||
} |
@@ -1,3 +0,2 @@ | ||
export * from './getFunctionName' | ||
export * from './handleError' | ||
export * from './isError' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Yes
NaN25263
-28.53%51
-20.31%181
-38.64%