@trayio/commons 1.1.0 → 1.3.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.
@@ -0,0 +1,9 @@
1
+ export type CallSite = {
2
+ filePath: string;
3
+ folderPath: string;
4
+ };
5
+ export interface CallSiteInterface {
6
+ getCurrentCallSites: () => Array<CallSite>;
7
+ }
8
+ export declare const CallSite: CallSiteInterface;
9
+ //# sourceMappingURL=CallSite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CallSite.d.ts","sourceRoot":"","sources":["../../src/callsite/CallSite.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IACjC,mBAAmB,EAAE,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,QAAQ,EAAE,iBAsBtB,CAAC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.CallSite = void 0;
27
+ const pathLib = __importStar(require("path"));
28
+ exports.CallSite = {
29
+ getCurrentCallSites: () => {
30
+ let callSites = [];
31
+ const _prepareStackTrace = Error.prepareStackTrace;
32
+ Error.prepareStackTrace = (_, stack) => {
33
+ callSites = stack.slice(2); // do not include this function and the immediate caller function
34
+ return stack;
35
+ };
36
+ new Error().stack; // eslint-disable-line @typescript-eslint/no-unused-expressions
37
+ Error.prepareStackTrace = _prepareStackTrace;
38
+ const result = callSites
39
+ .filter((callSite) => callSite.getFileName() !== null) // skip iterations
40
+ .map((callSite) => {
41
+ const filePath = callSite.getFileName();
42
+ const folderPath = pathLib.normalize(pathLib.join(filePath, '..'));
43
+ return {
44
+ filePath,
45
+ folderPath,
46
+ };
47
+ });
48
+ return result;
49
+ },
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/commons",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Extensions to the standard/core libraries and basic features",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"