Comparing version 2.1.1 to 3.0.0
@@ -0,0 +0,0 @@ import Jinter from './main.js'; |
@@ -0,0 +0,0 @@ import Jinter from './main.js'; |
@@ -22,3 +22,3 @@ import Visitor from './visitor.js'; | ||
*/ | ||
static parseScript(input: string): import("../acorn.js").ExtendNode<import("estree").Program>; | ||
static parseScript(input: string): import('../acorn.js').ExtendNode<import('estree').Program>; | ||
} |
@@ -25,2 +25,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
this.defineObject('String', String); | ||
this.defineObject('Number', Number); | ||
this.defineObject('Array', Array); | ||
@@ -27,0 +28,0 @@ this.defineObject('Date', Date); |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import { namedFunction } from '../utils/index.js'; |
import type ESTree from 'estree'; | ||
import BaseJSNode from './BaseJSNode.js'; | ||
export default class AssignmentExpression extends BaseJSNode<ESTree.AssignmentExpression> { | ||
private static operatorMap; | ||
private handleMemberExpression; | ||
private handleIdentifier; | ||
run(): any; | ||
} |
import BaseJSNode from './BaseJSNode.js'; | ||
export default class AssignmentExpression extends BaseJSNode { | ||
handleMemberExpression(leftNode, rightValue, operation) { | ||
const obj = this.visitor.visitNode(leftNode.object); | ||
const prop = this.visitor.visitNode(leftNode.property); | ||
const currentValue = obj[prop]; | ||
const newValue = operation(currentValue, rightValue); | ||
return (obj[prop] = newValue); | ||
} | ||
handleIdentifier(leftNode, rightValue, operation) { | ||
const currentValue = this.visitor.visitNode(leftNode); | ||
const newValue = operation(currentValue, rightValue); | ||
this.visitor.scope.set(leftNode.name, newValue); | ||
return this.visitor.scope.get(leftNode.name); | ||
} | ||
run() { | ||
const operator = this.node.operator; | ||
const right_node = this.visitor.visitNode(this.node.right); | ||
switch (operator) { | ||
case '=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] = right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
this.visitor.scope.set(this.node.left.name, right_node); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '+=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] += right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) + right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '-=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] -= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) - right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '*=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] *= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) * right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '/=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] /= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) / right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '%=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] %= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) % right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '**=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] **= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) ** right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '<<=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] <<= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) << right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '>>=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] >>= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) >> right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '>>>=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] >>>= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) >>> right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
case '&=': | ||
if (this.node.left.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.left.object); | ||
const prop = this.visitor.visitNode(this.node.left.property); | ||
return obj[prop] &= right_node; | ||
} | ||
else if (this.node.left.type === 'Identifier') { | ||
const result = this.visitor.visitNode(this.node.left) & right_node; | ||
this.visitor.scope.set(this.node.left.name, result); | ||
return this.visitor.scope.get(this.node.left.name); | ||
} | ||
console.warn('Unhandled left node', this.node.left); | ||
break; | ||
const { operator, left, right } = this.node; | ||
const rightValue = this.visitor.visitNode(right); | ||
const operation = AssignmentExpression.operatorMap[operator]; | ||
if (!operation) { | ||
console.warn('Unhandled operator:', operator); | ||
return undefined; | ||
} | ||
if (left.type === 'MemberExpression') { | ||
return this.handleMemberExpression(left, rightValue, operation); | ||
} | ||
else if (left.type === 'Identifier') { | ||
return this.handleIdentifier(left, rightValue, operation); | ||
} | ||
console.warn('Unhandled left node type:', left.type); | ||
return undefined; | ||
} | ||
} | ||
AssignmentExpression.operatorMap = { | ||
'=': (_, right) => right, | ||
'+=': (left, right) => left + right, | ||
'-=': (left, right) => left - right, | ||
'*=': (left, right) => left * right, | ||
'/=': (left, right) => left / right, | ||
'%=': (left, right) => left % right, | ||
'**=': (left, right) => left ** right, | ||
'<<=': (left, right) => left << right, | ||
'>>=': (left, right) => left >> right, | ||
'>>>=': (left, right) => left >>> right, | ||
'&=': (left, right) => left & right, | ||
'^=': (left, right) => left ^ right, | ||
'|=': (left, right) => left | right | ||
}; |
@@ -0,0 +0,0 @@ import ESTree from 'estree'; |
@@ -0,0 +0,0 @@ export default class BaseJSNode { |
import type ESTree from 'estree'; | ||
import BaseJSNode from './BaseJSNode.js'; | ||
export default class BinaryExpression extends BaseJSNode<ESTree.BinaryExpression> { | ||
private static operatorMap; | ||
run(): any; | ||
} |
import BaseJSNode from './BaseJSNode.js'; | ||
export default class BinaryExpression extends BaseJSNode { | ||
run() { | ||
const operator = this.node.operator; | ||
const left_node = this.visitor.visitNode(this.node.left); | ||
const right_node = this.visitor.visitNode(this.node.right); | ||
switch (operator) { | ||
case '!=': | ||
return left_node != right_node; | ||
case '!==': | ||
return left_node !== right_node; | ||
case '%': | ||
return left_node % right_node; | ||
case '&': | ||
return left_node & right_node; | ||
case '*': | ||
return left_node * right_node; | ||
case '**': | ||
return left_node ** right_node; | ||
case '+': | ||
return left_node + right_node; | ||
case '-': | ||
return left_node - right_node; | ||
case '/': | ||
return left_node / right_node; | ||
case '<': | ||
return left_node < right_node; | ||
case '<<': | ||
return left_node << right_node; | ||
case '<=': | ||
return left_node <= right_node; | ||
case '==': | ||
return left_node == right_node; | ||
case '===': | ||
return left_node === right_node; | ||
case '>': | ||
return left_node > right_node; | ||
case '>=': | ||
return left_node >= right_node; | ||
case '>>': | ||
return left_node >> right_node; | ||
case '>>>': | ||
return left_node >>> right_node; | ||
case '^': | ||
return left_node ^ right_node; | ||
case '|': | ||
return left_node | right_node; | ||
case 'in': | ||
return left_node in right_node; | ||
case 'instanceof': | ||
return left_node instanceof right_node; | ||
const { operator, left, right } = this.node; | ||
// Pre-evaluate both nodes. | ||
const leftValue = this.visitor.visitNode(left); | ||
const rightValue = this.visitor.visitNode(right); | ||
const operation = BinaryExpression.operatorMap[operator]; | ||
if (!operation) { | ||
console.warn('Unhandled binary operator:', operator); | ||
return undefined; | ||
} | ||
return operation(leftValue, rightValue); | ||
} | ||
} | ||
BinaryExpression.operatorMap = { | ||
// Comparison operators | ||
'!=': (left, right) => left != right, | ||
'!==': (left, right) => left !== right, | ||
'==': (left, right) => left == right, | ||
'===': (left, right) => left === right, | ||
'<': (left, right) => left < right, | ||
'<=': (left, right) => left <= right, | ||
'>': (left, right) => left > right, | ||
'>=': (left, right) => left >= right, | ||
// Arithmetic operators | ||
'+': (left, right) => left + right, | ||
'-': (left, right) => left - right, | ||
'*': (left, right) => left * right, | ||
'/': (left, right) => left / right, | ||
'%': (left, right) => left % right, | ||
'**': (left, right) => left ** right, | ||
// Bitwise operators | ||
'&': (left, right) => left & right, | ||
'|': (left, right) => left | right, | ||
'^': (left, right) => left ^ right, | ||
'<<': (left, right) => left << right, | ||
'>>': (left, right) => left >> right, | ||
'>>>': (left, right) => left >>> right, | ||
// Type checking operators | ||
'in': (left, right) => left in right, | ||
'instanceof': (left, right) => left instanceof right | ||
}; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -102,5 +102,4 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
static has(node, visitor) { | ||
var _a; | ||
if (node.callee.type === 'MemberExpression') { | ||
return !!((_a = this.builtins) === null || _a === void 0 ? void 0 : _a[visitor.getName(node.callee.property) || '']); | ||
return !!this.builtins?.[visitor.getName(node.callee.property) || '']; | ||
} | ||
@@ -107,0 +106,0 @@ return false; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import { namedFunction } from '../utils/index.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import { namedFunction } from '../utils/index.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ export { default as ArrayExpression } from './ArrayExpression.js'; |
@@ -1,2 +0,2 @@ | ||
// This file is auto-generated by ./scripts/build-nodes-map.js. | ||
// This file is generated automatically. Do not modify it. | ||
export { default as ArrayExpression } from './ArrayExpression.js'; | ||
@@ -3,0 +3,0 @@ export { default as ArrowFunctionExpression } from './ArrowFunctionExpression.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
import type ESTree from 'estree'; | ||
import BaseJSNode from './BaseJSNode.js'; | ||
export default class LogicalExpression extends BaseJSNode<ESTree.LogicalExpression> { | ||
private static operatorMap; | ||
run(): any; | ||
} |
import BaseJSNode from './BaseJSNode.js'; | ||
export default class LogicalExpression extends BaseJSNode { | ||
run() { | ||
const operator = this.node.operator; | ||
switch (operator) { | ||
case '&&': { | ||
const left_side = this.visitor.visitNode(this.node.left); | ||
if (left_side === true) | ||
return this.visitor.visitNode(this.node.right); | ||
return left_side; | ||
} | ||
case '||': { | ||
const left_side = this.visitor.visitNode(this.node.left); | ||
return left_side || this.visitor.visitNode(this.node.right); | ||
} | ||
case '??': { | ||
const left_side = this.visitor.visitNode(this.node.left); | ||
return left_side !== null && left_side !== void 0 ? left_side : this.visitor.visitNode(this.node.right); | ||
} | ||
const { operator, left, right } = this.node; | ||
const operation = LogicalExpression.operatorMap[operator]; | ||
if (!operation) { | ||
console.warn('Unhandled logical operator:', operator); | ||
return undefined; | ||
} | ||
return operation(this.visitor, left, right); | ||
} | ||
} | ||
LogicalExpression.operatorMap = { | ||
'&&': (visitor, leftNode, rightNode) => { | ||
const leftValue = visitor.visitNode(leftNode); | ||
return leftValue === true ? visitor.visitNode(rightNode) : leftValue; | ||
}, | ||
'||': (visitor, leftNode, rightNode) => { | ||
const leftValue = visitor.visitNode(leftNode); | ||
return leftValue || visitor.visitNode(rightNode); | ||
}, | ||
'??': (visitor, leftNode, rightNode) => { | ||
const normalizeUndefined = (value, isIdentifier) => isIdentifier && value === 'undefined' ? undefined : value; | ||
const leftValue = normalizeUndefined(visitor.visitNode(leftNode), leftNode.type === 'Identifier'); | ||
const rightValue = normalizeUndefined(visitor.visitNode(rightNode), rightNode.type === 'Identifier'); | ||
return leftValue ?? rightValue; | ||
} | ||
}; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -14,5 +14,5 @@ import BaseJSNode from './BaseJSNode.js'; | ||
} | ||
return obj === null || obj === void 0 ? void 0 : obj[prop]; | ||
return obj?.[prop]; | ||
} | ||
} | ||
} |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -7,3 +7,3 @@ import BaseJSNode from './BaseJSNode.js'; | ||
if (prop.type === 'Property') { | ||
result = Object.assign(Object.assign({}, result), this.visitor.visitNode(prop)); | ||
result = { ...result, ...this.visitor.visitNode(prop) }; | ||
} | ||
@@ -10,0 +10,0 @@ else { |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
import type ESTree from 'estree'; | ||
import BaseJSNode from './BaseJSNode.js'; | ||
export default class UnaryExpression extends BaseJSNode<ESTree.UnaryExpression> { | ||
run(): number | boolean | "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined; | ||
private static operatorMap; | ||
private static isValidOperator; | ||
run(): any; | ||
} |
import BaseJSNode from './BaseJSNode.js'; | ||
export default class UnaryExpression extends BaseJSNode { | ||
static isValidOperator(operator) { | ||
return operator in UnaryExpression.operatorMap; | ||
} | ||
run() { | ||
const operator = this.node.operator; | ||
switch (operator) { | ||
case '-': { | ||
const arg = this.visitor.visitNode(this.node.argument); | ||
return -arg; | ||
} | ||
case '+': { | ||
const arg = this.visitor.visitNode(this.node.argument); | ||
return +arg; | ||
} | ||
case '!': { | ||
const arg = this.visitor.visitNode(this.node.argument); | ||
return !arg; | ||
} | ||
case '~': { | ||
const arg = this.visitor.visitNode(this.node.argument); | ||
return ~arg; | ||
} | ||
case 'void': { | ||
this.visitor.visitNode(this.node.argument); | ||
return undefined; | ||
} | ||
case 'typeof': { | ||
const arg = this.visitor.visitNode(this.node.argument); | ||
return typeof arg; | ||
} | ||
case 'delete': { | ||
if (this.node.argument.type === 'MemberExpression') { | ||
const obj = this.visitor.visitNode(this.node.argument.object); | ||
const prop = this.node.argument.computed ? this.visitor.visitNode(this.node.argument.property) : this.visitor.getName(this.node.argument.property); | ||
return delete obj[prop]; | ||
} | ||
else if (this.node.argument.type === 'Identifier') { | ||
return this.visitor.scope.delete(this.node.argument.name); | ||
} | ||
return true; | ||
} | ||
default: | ||
console.warn('Unhandled UnaryExpression operator', operator); | ||
const { operator, argument } = this.node; | ||
if (!UnaryExpression.isValidOperator(operator)) { | ||
console.warn('Unhandled unary operator:', operator); | ||
return undefined; | ||
} | ||
return UnaryExpression.operatorMap[operator](this.visitor, argument); | ||
} | ||
} | ||
UnaryExpression.operatorMap = { | ||
// Arithmetic operators | ||
'-': (visitor, argument) => -visitor.visitNode(argument), | ||
'+': (visitor, argument) => +visitor.visitNode(argument), | ||
// Logical/Bitwise operators | ||
'!': (visitor, argument) => !visitor.visitNode(argument), | ||
'~': (visitor, argument) => ~visitor.visitNode(argument), | ||
// Type/Value operators | ||
'void': (visitor, argument) => { | ||
visitor.visitNode(argument); | ||
return undefined; | ||
}, | ||
'typeof': (visitor, argument) => { | ||
const arg = visitor.visitNode(argument); | ||
if (argument.type === 'Identifier' && arg === 'undefined') | ||
return 'undefined'; | ||
return typeof visitor.visitNode(argument); | ||
}, | ||
// Property/Variable deletion | ||
'delete': (visitor, argument) => { | ||
if (argument.type === 'MemberExpression') { | ||
const obj = visitor.visitNode(argument.object); | ||
const prop = argument.computed | ||
? visitor.visitNode(argument.property) | ||
: visitor.getName(argument.property); | ||
return delete obj[prop]; | ||
} | ||
if (argument.type === 'Identifier' && visitor.scope.has(argument.name)) { | ||
return visitor.scope.delete(argument.name); | ||
} | ||
return true; | ||
} | ||
}; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import type ESTree from 'estree'; |
@@ -0,0 +0,0 @@ import BaseJSNode from './BaseJSNode.js'; |
@@ -0,0 +0,0 @@ import ESTree from 'estree'; |
@@ -0,0 +0,0 @@ export const namedFunction = (name, fn) => Object.defineProperty(fn, 'name', { value: name }); |
@@ -0,0 +0,0 @@ import type { Node } from 'estree'; |
@@ -31,5 +31,5 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
return null; | ||
const target_node = __classPrivateFieldGet(this, _Visitor_instances, "m", _Visitor_getNode).call(this, node.type); | ||
if (target_node) { | ||
const instance = new target_node(node, this); | ||
const targetNode = __classPrivateFieldGet(this, _Visitor_instances, "m", _Visitor_getNode).call(this, node.type); | ||
if (targetNode) { | ||
const instance = new targetNode(node, this); | ||
return instance.run(); | ||
@@ -36,0 +36,0 @@ } |
{ | ||
"name": "jintr", | ||
"version": "2.1.1", | ||
"version": "3.0.0", | ||
"description": "A tiny JavaScript interpreter written in TypeScript.", | ||
"type": "module", | ||
"types": "./dist/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"./dist/index.d.ts" | ||
] | ||
} | ||
}, | ||
"exports": { | ||
".": { | ||
"node": { | ||
"import": "./dist/index.js", | ||
"require": "./bundle/jinter.cjs" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"module": "./dist/index.js", | ||
"scripts": { | ||
"test": "npx jest --verbose", | ||
"build": "npm run build:esm && npm run build:nodes-map && npm run bundle:node", | ||
"clean": "npx rimraf ./dist", | ||
"build": "npm run clean && npm run lint && npm run build:nodes-map && npm run build:esm", | ||
"build:esm": "npx tsc", | ||
"build:nodes-map": "node ./scripts/build-nodes-map.js", | ||
"lint": "npx eslint ./src/**/*.ts", | ||
"lint:fix": "npx eslint --fix ./src/**/*.ts", | ||
"build:esm": "npx tsc", | ||
"build:nodes-map": "node ./scripts/build-nodes-map.js", | ||
"bundle:node": "npx esbuild ./dist/index.js --bundle --outfile=./bundle/jinter.cjs --platform=node --target=node10 --format=cjs --sourcemap --banner:js=\"/* eslint-disable */\" --external:acorn", | ||
"prepare": "npm run build", | ||
"watch": "npx tsc --watch" | ||
"watch": "npx tsc --watch", | ||
"test": "vitest" | ||
}, | ||
@@ -47,14 +31,21 @@ "author": "LuanRT <luan.lrt4@gmail.com> (https://github.com/LuanRT)", | ||
"license": "MIT", | ||
"exports": { | ||
".": { | ||
"node": { | ||
"import": "./dist/index.js" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@types/estree": "^1.0.0", | ||
"@types/jest": "^28.1.8", | ||
"@types/glob": "^8.1.0", | ||
"@typescript-eslint/eslint-plugin": "^5.33.1", | ||
"@typescript-eslint/parser": "^5.33.1", | ||
"esbuild": "^0.17.15", | ||
"eslint": "^8.22.0", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
"glob": "^8.0.3", | ||
"jest": "^28.1.3", | ||
"ts-jest": "^28.0.8", | ||
"typescript": "^4.9.5" | ||
"typescript": "^4.9.5", | ||
"vitest": "^2.1.3" | ||
}, | ||
@@ -67,3 +58,7 @@ "dependencies": { | ||
}, | ||
"homepage": "https://github.com/LuanRT/Jinter#readme" | ||
} | ||
"homepage": "https://github.com/LuanRT/Jinter#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/LuanRT/Jinter.git" | ||
} | ||
} |
@@ -0,0 +0,0 @@ [actions]: https://github.com/LuanRT/Jinter/actions |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
9
0
57070
83
1302