add.js 381 B

1234567891011121314
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. // https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add
  4. module.exports = function BigIntAdd(x, y) {
  5. if (typeof x !== 'bigint' || typeof y !== 'bigint') {
  6. throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
  7. }
  8. // shortcut for the actual spec mechanics
  9. return x + y;
  10. };