BinaryOr.js 314 B

123456789101112
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. // https://262.ecma-international.org/11.0/#sec-binaryor
  4. module.exports = function BinaryOr(x, y) {
  5. if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) {
  6. throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1');
  7. }
  8. return x | y;
  9. };