SameValueNonNumeric.js 573 B

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