backtracker
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -7,2 +7,11 @@ "use strict"; | ||
class Caller { | ||
path; | ||
dir; | ||
filename; | ||
async; | ||
scope; | ||
line; | ||
column; | ||
anonymous; | ||
parent; | ||
constructor(details) { | ||
@@ -9,0 +18,0 @@ this.path = details.path; |
@@ -5,3 +5,2 @@ "use strict"; | ||
}; | ||
const Caller_1 = __importDefault(require("./Caller")); | ||
@@ -16,8 +15,7 @@ const Stack_1 = __importDefault(require("./Stack")); | ||
]; | ||
class BackTracker { | ||
parent; | ||
constructor() { | ||
this.parent = BackTracker.stack.first(); | ||
} | ||
static get stack() { | ||
@@ -30,6 +28,4 @@ const stack = new Error().stack; | ||
} | ||
const split = stack.split("\n"); | ||
const frames = split.slice(3, split.length).map(item => item.trim()); | ||
for (const frame of frames) { | ||
@@ -41,3 +37,2 @@ const test1 = evalreg.exec(frame); | ||
} | ||
const test2 = somethingreg.exec(frame); | ||
@@ -48,3 +43,2 @@ if (test2 && test2.length > 0) { | ||
} | ||
const test3 = namedreg.exec(frame); | ||
@@ -55,3 +49,2 @@ if (test3 && test3.length > 0) { | ||
} | ||
const test4 = anonymousreg.exec(frame); | ||
@@ -62,3 +55,2 @@ if (test4 && test4.length > 0) { | ||
} | ||
const test5 = notnamedreg.exec(frame); | ||
@@ -69,3 +61,2 @@ if (test5 && test5.length > 0) { | ||
} | ||
for (const caller of callers) { | ||
@@ -78,3 +69,2 @@ const index = callers.indexOf(caller); | ||
} | ||
module.exports = { | ||
@@ -81,0 +71,0 @@ BackTracker, |
declare class Stack extends Array<import("./Caller")> { | ||
constructor(); | ||
first(amount?: number): import("./Caller") | Array<import("./Caller")>; | ||
last(amount?: number): import("./Caller") | Array<import("./Caller")>; | ||
first(): import("./Caller"); | ||
first(amount: number): Array<import("./Caller")>; | ||
last(): import("./Caller"); | ||
last(amount: number): Array<import("./Caller")>; | ||
} | ||
export = Stack; |
@@ -6,18 +6,17 @@ "use strict"; | ||
} | ||
first(amount) { | ||
if (!Number.isInteger(amount) || amount === 0) return this[0]; | ||
if (amount < 0) return this.last(amount * -1); | ||
if (!amount) | ||
return this[0]; | ||
if (amount < 0) | ||
return this.last(amount * -1); | ||
return this.slice(0, amount); | ||
} | ||
last(amount) { | ||
if (!Number.isInteger(amount) || amount === 0) return this[this.length - 1]; | ||
if (amount < 0) return this.first(amount * -1); | ||
if (!amount) | ||
return this[this.length - 1]; | ||
if (amount < 0) | ||
return this.first(amount * -1); | ||
return this.slice(-amount); | ||
} | ||
} | ||
module.exports = Stack; |
{ | ||
"name": "backtracker", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Back track in JS code execution and find where a function was called", | ||
@@ -26,4 +26,5 @@ "main": "dist/index", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"README.md" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159
24851