Comparing version 3.1.0 to 3.2.0
@@ -49,9 +49,4 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
evaluate(input) { | ||
try { | ||
const program = parse(input, { ecmaVersion: 2020 }); | ||
__classPrivateFieldSet(this, _Jinter_ast, program.body, "f"); | ||
} | ||
catch (e) { | ||
throw new JinterError(e.message); | ||
} | ||
const program = Jinter.parseScript(input); | ||
__classPrivateFieldSet(this, _Jinter_ast, program.body, "f"); | ||
this.visitor.setAST(__classPrivateFieldGet(this, _Jinter_ast, "f")); | ||
@@ -68,3 +63,14 @@ return this.visitor.run(); | ||
catch (e) { | ||
throw new JinterError(e.message); | ||
const match = e.message.match(/\((\d+):(\d+)\)/); | ||
if (match) { | ||
const line = parseInt(match[1], 10); | ||
const column = parseInt(match[2], 10); | ||
const lines = input.split('\n'); | ||
const errorLine = lines[line - 1]; | ||
const snippet = errorLine ? errorLine.substring(Math.max(0, column - 10), column + 10) : ''; | ||
throw new JinterError(`${e.message.replace(/\(.*\)/, '').trim()} at line ${line}, column ${column}: ${snippet}`, { errorLine }); | ||
} | ||
else { | ||
throw new JinterError(e.message); | ||
} | ||
} | ||
@@ -71,0 +77,0 @@ } |
{ | ||
"name": "jintr", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "A tiny JavaScript interpreter written in TypeScript.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
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
57338
1313
2