bitwiseNOT.js 417 B

123456789101112131415
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $BigInt = GetIntrinsic('%BigInt%', true);
  4. var $TypeError = require('es-errors/type');
  5. // https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT
  6. module.exports = function BigIntBitwiseNOT(x) {
  7. if (typeof x !== 'bigint') {
  8. throw new $TypeError('Assertion failed: `x` argument must be a BigInt');
  9. }
  10. return -x - $BigInt(1);
  11. };