binaryOperation.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. exports.__esModule = true;
  3. function binaryOperation(operator, left, right) {
  4. switch (operator) {
  5. case '+':
  6. return left + right;
  7. case '-':
  8. return left - right;
  9. case '/':
  10. return left / right;
  11. case '%':
  12. return left % right;
  13. case '*':
  14. return left * right;
  15. case '**':
  16. return Math.pow(left, right);
  17. case '&':
  18. return left & right;
  19. case '|':
  20. return left | right;
  21. case '>>':
  22. return left >> right;
  23. case '>>>':
  24. return left >>> right;
  25. case '<<':
  26. return left << right;
  27. case '^':
  28. return left ^ right;
  29. case '==':
  30. return left == right;
  31. case '===':
  32. return left === right;
  33. case '!=':
  34. return left != right;
  35. case '!==':
  36. return left !== right;
  37. case 'in':
  38. return left in right;
  39. case 'instanceof':
  40. return left instanceof right;
  41. case '>':
  42. return left > right;
  43. case '<':
  44. return left < right;
  45. case '>=':
  46. return left >= right;
  47. case '<=':
  48. return left <= right;
  49. }
  50. }
  51. exports["default"] = binaryOperation;