lessThan.js 564 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var isNaN = require('../../helpers/isNaN');
  4. // https://262.ecma-international.org/11.0/#sec-numeric-types-number-lessThan
  5. module.exports = function NumberLessThan(x, y) {
  6. if (typeof x !== 'number' || typeof y !== 'number') {
  7. throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
  8. }
  9. // If x is NaN, return undefined.
  10. // If y is NaN, return undefined.
  11. if (isNaN(x) || isNaN(y)) {
  12. return void undefined;
  13. }
  14. // shortcut for the actual spec mechanics
  15. return x < y;
  16. };