BinaryXor.js 316 B

123456789101112
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. // https://262.ecma-international.org/11.0/#sec-binaryxor
  4. module.exports = function BinaryXor(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. };