@xylabs/error 2.13.5 → 2.13.7

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.
Files changed (37) hide show
  1. package/dist/browser/index.cjs +0 -22
  2. package/dist/browser/index.cjs.map +1 -1
  3. package/dist/browser/index.d.cts +0 -1
  4. package/dist/browser/index.d.cts.map +1 -1
  5. package/dist/browser/index.d.mts +0 -1
  6. package/dist/browser/index.d.mts.map +1 -1
  7. package/dist/browser/index.d.ts +0 -1
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/index.js +0 -22
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/node/index.cjs +55 -0
  12. package/dist/node/index.cjs.map +1 -0
  13. package/dist/node/index.d.cts +0 -1
  14. package/dist/node/index.d.cts.map +1 -1
  15. package/dist/node/index.d.mts +0 -1
  16. package/dist/node/index.d.mts.map +1 -1
  17. package/dist/node/index.d.ts +0 -1
  18. package/dist/node/index.d.ts.map +1 -1
  19. package/dist/node/index.js +2 -55
  20. package/dist/node/index.js.map +1 -1
  21. package/package.json +8 -7
  22. package/src/index.ts +0 -1
  23. package/dist/browser/getFunctionName.d.cts +0 -2
  24. package/dist/browser/getFunctionName.d.cts.map +0 -1
  25. package/dist/browser/getFunctionName.d.mts +0 -2
  26. package/dist/browser/getFunctionName.d.mts.map +0 -1
  27. package/dist/browser/getFunctionName.d.ts +0 -2
  28. package/dist/browser/getFunctionName.d.ts.map +0 -1
  29. package/dist/node/getFunctionName.d.cts +0 -2
  30. package/dist/node/getFunctionName.d.cts.map +0 -1
  31. package/dist/node/getFunctionName.d.mts +0 -2
  32. package/dist/node/getFunctionName.d.mts.map +0 -1
  33. package/dist/node/getFunctionName.d.ts +0 -2
  34. package/dist/node/getFunctionName.d.ts.map +0 -1
  35. package/dist/node/index.mjs +0 -49
  36. package/dist/node/index.mjs.map +0 -1
  37. package/src/getFunctionName.ts +0 -23
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- getFunctionName: () => getFunctionName,
24
23
  handleError: () => handleError,
25
24
  handleErrorAsync: () => handleErrorAsync,
26
25
  isError: () => isError
@@ -47,25 +46,4 @@ var handleErrorAsync = async (error, handler) => {
47
46
  throw error;
48
47
  }
49
48
  };
50
-
51
- // src/getFunctionName.ts
52
- var getFunctionName = (depth = 2) => {
53
- try {
54
- throw Error();
55
- } catch (ex) {
56
- return handleError(ex, (error) => {
57
- let newIndex = void 0;
58
- const stackParts = error.stack?.split("\n")[depth].split(" ");
59
- const funcName = stackParts?.find((item, index) => {
60
- if (item.length > 0 && item !== "at") {
61
- if (item === "new") {
62
- newIndex = index;
63
- }
64
- return item;
65
- }
66
- }) ?? "<unknown>";
67
- return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName;
68
- });
69
- }
70
- };
71
49
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/isError.ts","../../src/handleError.ts","../../src/getFunctionName.ts"],"sourcesContent":["export * from './getFunctionName'\nexport * from './handleError'\nexport * from './isError'\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n","import { handleError } from './handleError'\n\nexport const getFunctionName = (depth = 2) => {\n try {\n throw Error()\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined = undefined\n const stackParts = error.stack?.split('\\n')[depth].split(' ')\n const funcName =\n stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n //check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return item\n }\n }) ?? '<unknown>'\n return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;;;AChBO,IAAM,kBAAkB,CAAC,QAAQ,MAAM;AAC5C,MAAI;AACF,UAAM,MAAM;AAAA,EACd,SAAS,IAAI;AACX,WAAO,YAAY,IAAI,CAAC,UAAU;AAChC,UAAI,WAA+B;AACnC,YAAM,aAAa,MAAM,OAAO,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG;AAC5D,YAAM,WACJ,YAAY,KAAK,CAAC,MAAM,UAAU;AAChC,YAAI,KAAK,SAAS,KAAK,SAAS,MAAM;AAEpC,cAAI,SAAS,OAAO;AAClB,uBAAW;AAAA,UACb;AACA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC,KAAK;AACR,aAAO,WAAW,GAAG,QAAQ,IAAI,aAAa,WAAW,CAAC,CAAC,KAAK;AAAA,IAClE,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/isError.ts","../../src/handleError.ts"],"sourcesContent":["export * from './handleError'\nexport * from './isError'\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -1,4 +1,3 @@
1
- export * from './getFunctionName';
2
1
  export * from './handleError';
3
2
  export * from './isError';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -1,4 +1,3 @@
1
- export * from './getFunctionName';
2
1
  export * from './handleError';
3
2
  export * from './isError';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -1,4 +1,3 @@
1
- export * from './getFunctionName';
2
1
  export * from './handleError';
3
2
  export * from './isError';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -18,29 +18,7 @@ var handleErrorAsync = async (error, handler) => {
18
18
  throw error;
19
19
  }
20
20
  };
21
-
22
- // src/getFunctionName.ts
23
- var getFunctionName = (depth = 2) => {
24
- try {
25
- throw Error();
26
- } catch (ex) {
27
- return handleError(ex, (error) => {
28
- let newIndex = void 0;
29
- const stackParts = error.stack?.split("\n")[depth].split(" ");
30
- const funcName = stackParts?.find((item, index) => {
31
- if (item.length > 0 && item !== "at") {
32
- if (item === "new") {
33
- newIndex = index;
34
- }
35
- return item;
36
- }
37
- }) ?? "<unknown>";
38
- return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName;
39
- });
40
- }
41
- };
42
21
  export {
43
- getFunctionName,
44
22
  handleError,
45
23
  handleErrorAsync,
46
24
  isError
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isError.ts","../../src/handleError.ts","../../src/getFunctionName.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n","import { handleError } from './handleError'\n\nexport const getFunctionName = (depth = 2) => {\n try {\n throw Error()\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined = undefined\n const stackParts = error.stack?.split('\\n')[depth].split(' ')\n const funcName =\n stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n //check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return item\n }\n }) ?? '<unknown>'\n return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n"],"mappings":";AACO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;;;AChBO,IAAM,kBAAkB,CAAC,QAAQ,MAAM;AAC5C,MAAI;AACF,UAAM,MAAM;AAAA,EACd,SAAS,IAAI;AACX,WAAO,YAAY,IAAI,CAAC,UAAU;AAChC,UAAI,WAA+B;AACnC,YAAM,aAAa,MAAM,OAAO,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG;AAC5D,YAAM,WACJ,YAAY,KAAK,CAAC,MAAM,UAAU;AAChC,YAAI,KAAK,SAAS,KAAK,SAAS,MAAM;AAEpC,cAAI,SAAS,OAAO;AAClB,uBAAW;AAAA,UACb;AACA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC,KAAK;AACR,aAAO,WAAW,GAAG,QAAQ,IAAI,aAAa,WAAW,CAAC,CAAC,KAAK;AAAA,IAClE,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/isError.ts","../../src/handleError.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n"],"mappings":";AACO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ handleError: () => handleError,
24
+ handleErrorAsync: () => handleErrorAsync,
25
+ isError: () => isError
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/isError.ts
30
+ var isError = (error) => {
31
+ return typeof error.message === "string" && typeof error.name === "string";
32
+ };
33
+
34
+ // src/handleError.ts
35
+ var handleError = (error, handler) => {
36
+ if (isError(error)) {
37
+ return handler(error);
38
+ } else {
39
+ throw error;
40
+ }
41
+ };
42
+ var handleErrorAsync = async (error, handler) => {
43
+ if (isError(error)) {
44
+ return await handler(error);
45
+ } else {
46
+ throw error;
47
+ }
48
+ };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ handleError,
52
+ handleErrorAsync,
53
+ isError
54
+ });
55
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/isError.ts","../../src/handleError.ts"],"sourcesContent":["export * from './handleError'\nexport * from './isError'\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -1,4 +1,3 @@
1
- export * from './getFunctionName';
2
1
  export * from './handleError';
3
2
  export * from './isError';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -1,4 +1,3 @@
1
- export * from './getFunctionName';
2
1
  export * from './handleError';
3
2
  export * from './isError';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -1,4 +1,3 @@
1
- export * from './getFunctionName';
2
1
  export * from './handleError';
3
2
  export * from './isError';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -1,32 +1,3 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- getFunctionName: () => getFunctionName,
24
- handleError: () => handleError,
25
- handleErrorAsync: () => handleErrorAsync,
26
- isError: () => isError
27
- });
28
- module.exports = __toCommonJS(src_exports);
29
-
30
1
  // src/isError.ts
31
2
  var isError = (error) => {
32
3
  return typeof error.message === "string" && typeof error.name === "string";
@@ -47,33 +18,9 @@ var handleErrorAsync = async (error, handler) => {
47
18
  throw error;
48
19
  }
49
20
  };
50
-
51
- // src/getFunctionName.ts
52
- var getFunctionName = (depth = 2) => {
53
- try {
54
- throw Error();
55
- } catch (ex) {
56
- return handleError(ex, (error) => {
57
- var _a;
58
- let newIndex = void 0;
59
- const stackParts = (_a = error.stack) == null ? void 0 : _a.split("\n")[depth].split(" ");
60
- const funcName = (stackParts == null ? void 0 : stackParts.find((item, index) => {
61
- if (item.length > 0 && item !== "at") {
62
- if (item === "new") {
63
- newIndex = index;
64
- }
65
- return item;
66
- }
67
- })) ?? "<unknown>";
68
- return newIndex ? `${funcName} ${stackParts == null ? void 0 : stackParts[newIndex + 1]}` : funcName;
69
- });
70
- }
71
- };
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- getFunctionName,
21
+ export {
75
22
  handleError,
76
23
  handleErrorAsync,
77
24
  isError
78
- });
25
+ };
79
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/isError.ts","../../src/handleError.ts","../../src/getFunctionName.ts"],"sourcesContent":["export * from './getFunctionName'\nexport * from './handleError'\nexport * from './isError'\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n","import { handleError } from './handleError'\n\nexport const getFunctionName = (depth = 2) => {\n try {\n throw Error()\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined = undefined\n const stackParts = error.stack?.split('\\n')[depth].split(' ')\n const funcName =\n stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n //check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return item\n }\n }) ?? '<unknown>'\n return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;;;AChBO,IAAM,kBAAkB,CAAC,QAAQ,MAAM;AAC5C,MAAI;AACF,UAAM,MAAM;AAAA,EACd,SAAS,IAAI;AACX,WAAO,YAAY,IAAI,CAAC,UAAU;AANtC;AAOM,UAAI,WAA+B;AACnC,YAAM,cAAa,WAAM,UAAN,mBAAa,MAAM,MAAM,OAAO,MAAM;AACzD,YAAM,YACJ,yCAAY,KAAK,CAAC,MAAM,UAAU;AAChC,YAAI,KAAK,SAAS,KAAK,SAAS,MAAM;AAEpC,cAAI,SAAS,OAAO;AAClB,uBAAW;AAAA,UACb;AACA,iBAAO;AAAA,QACT;AAAA,MACF,OAAM;AACR,aAAO,WAAW,GAAG,QAAQ,IAAI,yCAAa,WAAW,EAAE,KAAK;AAAA,IAClE,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/isError.ts","../../src/handleError.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n"],"mappings":";AACO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;","names":[]}
package/package.json CHANGED
@@ -31,19 +31,20 @@
31
31
  },
32
32
  "node": {
33
33
  "require": {
34
- "types": "./dist/node/index.d.ts",
35
- "default": "./dist/node/index.js"
34
+ "types": "./dist/node/index.d.cts",
35
+ "default": "./dist/node/index.cjs"
36
36
  },
37
37
  "import": {
38
38
  "types": "./dist/node/index.d.mts",
39
- "default": "./dist/node/index.mjs"
39
+ "default": "./dist/node/index.js"
40
40
  }
41
41
  }
42
42
  },
43
43
  "./package.json": "./package.json"
44
44
  },
45
- "main": "dist/node/index.js",
46
- "module": "dist/node/index.mjs",
45
+ "main": "dist/node/index.cjs",
46
+ "module": "dist/node/index.js",
47
+ "types": "dist/node/index.d.mts",
47
48
  "homepage": "https://xyo.network",
48
49
  "license": "LGPL-3.0-only",
49
50
  "publishConfig": {
@@ -54,6 +55,6 @@
54
55
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
55
56
  },
56
57
  "sideEffects": false,
57
- "types": "dist/node/index.d.ts",
58
- "version": "2.13.5"
58
+ "version": "2.13.7",
59
+ "type": "module"
59
60
  }
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './getFunctionName'
2
1
  export * from './handleError'
3
2
  export * from './isError'
@@ -1,2 +0,0 @@
1
- export declare const getFunctionName: (depth?: number) => string;
2
- //# sourceMappingURL=getFunctionName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFunctionName.d.ts","sourceRoot":"","sources":["../../src/getFunctionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAoB3B,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const getFunctionName: (depth?: number) => string;
2
- //# sourceMappingURL=getFunctionName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFunctionName.d.ts","sourceRoot":"","sources":["../../src/getFunctionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAoB3B,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const getFunctionName: (depth?: number) => string;
2
- //# sourceMappingURL=getFunctionName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFunctionName.d.ts","sourceRoot":"","sources":["../../src/getFunctionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAoB3B,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const getFunctionName: (depth?: number) => string;
2
- //# sourceMappingURL=getFunctionName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFunctionName.d.ts","sourceRoot":"","sources":["../../src/getFunctionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAoB3B,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const getFunctionName: (depth?: number) => string;
2
- //# sourceMappingURL=getFunctionName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFunctionName.d.ts","sourceRoot":"","sources":["../../src/getFunctionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAoB3B,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const getFunctionName: (depth?: number) => string;
2
- //# sourceMappingURL=getFunctionName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFunctionName.d.ts","sourceRoot":"","sources":["../../src/getFunctionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAoB3B,CAAA"}
@@ -1,49 +0,0 @@
1
- // src/isError.ts
2
- var isError = (error) => {
3
- return typeof error.message === "string" && typeof error.name === "string";
4
- };
5
-
6
- // src/handleError.ts
7
- var handleError = (error, handler) => {
8
- if (isError(error)) {
9
- return handler(error);
10
- } else {
11
- throw error;
12
- }
13
- };
14
- var handleErrorAsync = async (error, handler) => {
15
- if (isError(error)) {
16
- return await handler(error);
17
- } else {
18
- throw error;
19
- }
20
- };
21
-
22
- // src/getFunctionName.ts
23
- var getFunctionName = (depth = 2) => {
24
- try {
25
- throw Error();
26
- } catch (ex) {
27
- return handleError(ex, (error) => {
28
- var _a;
29
- let newIndex = void 0;
30
- const stackParts = (_a = error.stack) == null ? void 0 : _a.split("\n")[depth].split(" ");
31
- const funcName = (stackParts == null ? void 0 : stackParts.find((item, index) => {
32
- if (item.length > 0 && item !== "at") {
33
- if (item === "new") {
34
- newIndex = index;
35
- }
36
- return item;
37
- }
38
- })) ?? "<unknown>";
39
- return newIndex ? `${funcName} ${stackParts == null ? void 0 : stackParts[newIndex + 1]}` : funcName;
40
- });
41
- }
42
- };
43
- export {
44
- getFunctionName,
45
- handleError,
46
- handleErrorAsync,
47
- isError
48
- };
49
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/isError.ts","../../src/handleError.ts","../../src/getFunctionName.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isError = (error: any): error is Error => {\n return typeof error.message === 'string' && typeof error.name === 'string'\n}\n","import { isError } from './isError'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleError = <T>(error: any, handler: (error: Error) => T) => {\n if (isError(error)) {\n return handler(error)\n } else {\n throw error\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const handleErrorAsync = async <T>(error: any, handler: (error: Error) => Promise<T>) => {\n if (isError(error)) {\n return await handler(error)\n } else {\n throw error\n }\n}\n","import { handleError } from './handleError'\n\nexport const getFunctionName = (depth = 2) => {\n try {\n throw Error()\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined = undefined\n const stackParts = error.stack?.split('\\n')[depth].split(' ')\n const funcName =\n stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n //check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return item\n }\n }) ?? '<unknown>'\n return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n"],"mappings":";AACO,IAAM,UAAU,CAAC,UAA+B;AACrD,SAAO,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,SAAS;AACpE;;;ACAO,IAAM,cAAc,CAAI,OAAY,YAAiC;AAC1E,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,KAAK;AAAA,EACtB,OAAO;AACL,UAAM;AAAA,EACR;AACF;AAGO,IAAM,mBAAmB,OAAU,OAAY,YAA0C;AAC9F,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,MAAM,QAAQ,KAAK;AAAA,EAC5B,OAAO;AACL,UAAM;AAAA,EACR;AACF;;;AChBO,IAAM,kBAAkB,CAAC,QAAQ,MAAM;AAC5C,MAAI;AACF,UAAM,MAAM;AAAA,EACd,SAAS,IAAI;AACX,WAAO,YAAY,IAAI,CAAC,UAAU;AANtC;AAOM,UAAI,WAA+B;AACnC,YAAM,cAAa,WAAM,UAAN,mBAAa,MAAM,MAAM,OAAO,MAAM;AACzD,YAAM,YACJ,yCAAY,KAAK,CAAC,MAAM,UAAU;AAChC,YAAI,KAAK,SAAS,KAAK,SAAS,MAAM;AAEpC,cAAI,SAAS,OAAO;AAClB,uBAAW;AAAA,UACb;AACA,iBAAO;AAAA,QACT;AAAA,MACF,OAAM;AACR,aAAO,WAAW,GAAG,QAAQ,IAAI,yCAAa,WAAW,EAAE,KAAK;AAAA,IAClE,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,23 +0,0 @@
1
- import { handleError } from './handleError'
2
-
3
- export const getFunctionName = (depth = 2) => {
4
- try {
5
- throw Error()
6
- } catch (ex) {
7
- return handleError(ex, (error) => {
8
- let newIndex: number | undefined = undefined
9
- const stackParts = error.stack?.split('\n')[depth].split(' ')
10
- const funcName =
11
- stackParts?.find((item, index) => {
12
- if (item.length > 0 && item !== 'at') {
13
- //check if constructor
14
- if (item === 'new') {
15
- newIndex = index
16
- }
17
- return item
18
- }
19
- }) ?? '<unknown>'
20
- return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName
21
- })
22
- }
23
- }