devsite/node_modules/constantinople/lib/binaryOperation.js

52 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2024-07-08 01:49:38 +00:00
"use strict";
exports.__esModule = true;
function binaryOperation(operator, left, right) {
switch (operator) {
case '+':
return left + right;
case '-':
return left - right;
case '/':
return left / right;
case '%':
return left % right;
case '*':
return left * right;
case '**':
return Math.pow(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;
}
}
exports["default"] = binaryOperation;