SameValueNonNumber.js 551 B

12345678910111213141516171819
  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/14.0/#sec-samevaluenonnumeric
  6. module.exports = function SameValueNonNumber(x, y) {
  7. var xType = Type(x);
  8. if (xType === 'Number') {
  9. throw new $TypeError('Assertion failed: SameValueNonNumber does not accept Number values');
  10. }
  11. if (xType !== Type(y)) {
  12. throw new $TypeError('SameValueNonNumber requires two non-Number values of the same type.');
  13. }
  14. return SameValue(x, y);
  15. };