BinaryOr.js 362 B

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