mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-12-01 13:09:26 +01:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
"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;
|