-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite in typescript and actually evaluate the AST instead of evaling
- Loading branch information
1 parent
d9b4c71
commit 01d409c
Showing
8 changed files
with
533 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ logs | |
results | ||
npm-debug.log | ||
node_modules | ||
lib | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
export type Operator = | ||
| '+' | ||
| '-' | ||
| '/' | ||
| '%' | ||
| '*' | ||
| '**' | ||
| '&' | ||
| '|' | ||
| '>>' | ||
| '>>>' | ||
| '<<' | ||
| '^' | ||
| '==' | ||
| '===' | ||
| '!=' | ||
| '!==' | ||
| 'in' | ||
| 'instanceof' | ||
| '>' | ||
| '<' | ||
| '>=' | ||
| '<='; | ||
|
||
export default function binaryOperation( | ||
operator: Operator, | ||
left: any, | ||
right: any, | ||
): any { | ||
switch (operator) { | ||
case '+': | ||
return left + right; | ||
case '-': | ||
return left - right; | ||
case '/': | ||
return left / right; | ||
case '%': | ||
return left % right; | ||
case '*': | ||
return left * right; | ||
case '**': | ||
return left ** right; | ||
case '&': | ||
return left & right; | ||
case '|': | ||
return left | right; | ||
case '>>': | ||
return left >> right; | ||
case '>>>': | ||
return left >>> right; | ||
case '<<': | ||
return left << right; | ||
case '^': | ||
return left ^ right; | ||
case '==': | ||
return left == right; | ||
case '===': | ||
return left === right; | ||
case '!=': | ||
return left != right; | ||
case '!==': | ||
return left !== right; | ||
case 'in': | ||
return left in right; | ||
case 'instanceof': | ||
return left instanceof right; | ||
case '>': | ||
return left > right; | ||
case '<': | ||
return left < right; | ||
case '>=': | ||
return left >= right; | ||
case '<=': | ||
return left <= right; | ||
} | ||
} |
Oops, something went wrong.
01d409c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrección de seguridad
01d409c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the security issue here?
01d409c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. Got it.