SameValueNonNumeric.js 635 B

123456789101112131415161718192021
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var SameValue = require('./SameValue');
  5. var Type = require('./Type');
  6. // https://262.ecma-international.org/11.0/#sec-samevaluenonnumeric
  7. module.exports = function SameValueNonNumeric(x, y) {
  8. var xType = Type(x);
  9. if (xType === 'Number' || xType === 'Bigint') {
  10. throw new $TypeError('Assertion failed: SameValueNonNumeric does not accept Number or BigInt values');
  11. }
  12. if (xType !== Type(y)) {
  13. throw new $TypeError('SameValueNonNumeric requires two non-numeric values of the same type.');
  14. }
  15. return SameValue(x, y);
  16. };