subtract.js 425 B

12345678910111213141516
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var Type = require('../Type');
  5. // https://262.ecma-international.org/11.0/#sec-numeric-types-number-subtract
  6. module.exports = function NumberSubtract(x, y) {
  7. if (Type(x) !== 'Number' || Type(y) !== 'Number') {
  8. throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
  9. }
  10. return x - y;
  11. };