diff options
Diffstat (limited to 'src/node_modules/es-abstract/2020/BinaryAnd.js')
-rw-r--r-- | src/node_modules/es-abstract/2020/BinaryAnd.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/node_modules/es-abstract/2020/BinaryAnd.js b/src/node_modules/es-abstract/2020/BinaryAnd.js new file mode 100644 index 0000000..f06d41c --- /dev/null +++ b/src/node_modules/es-abstract/2020/BinaryAnd.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://tc39.es/ecma262/2020/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; |