Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed May 11, 2023
1 parent d046da7 commit 244a569
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/lib/stackframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ function _capitalize(str) {
return str.charAt(0).toUpperCase() + str.substring(1);
}

function _getter(p) {
return function () {
// @ts-ignore
return this[p];
};
function _getter(t, p): any {
// return function () {
// @ts-ignore
return t[p];
// };
}

const booleanProps = ['isConstructor', 'isEval', 'isNative', 'isToplevel'];
Expand All @@ -25,6 +25,15 @@ const props = booleanProps.concat(numericProps, stringProps, arrayProps, objectP
export class StackFrame {
args = [];
evalOrigin = {};
fileName = '';
functionName = '';
isConstructor = false;
isEval = false;
isNative = false;
isToplevel = false;
lineNumber = 0;
source = '';
columnNumber = 0;

constructor(obj) {
if (!obj) return;
Expand Down Expand Up @@ -88,19 +97,19 @@ export class StackFrame {
}

getFileName() {
return _getter('fileName');
return _getter(this, 'fileName') as string;
}
getLineNumber() {
return _getter('lineNumber');
return _getter(this, 'lineNumber') as number;
}
getColumnNumber() {
return _getter('columnNumber');
return _getter(this, 'columnNumber') as number;
}
getFunctionName() {
return _getter('functionName');
return _getter(this, 'functionName') as string;
}
getIsEval() {
return _getter('isEval');
return _getter(this, 'isEval');
}

fromString(str) {
Expand Down

0 comments on commit 244a569

Please sign in to comment.