IsIntegralNumber.js 473 B

123456789101112131415161718
  1. 'use strict';
  2. var abs = require('./abs');
  3. var floor = require('./floor');
  4. var Type = require('./Type');
  5. var $isNaN = require('../helpers/isNaN');
  6. var $isFinite = require('../helpers/isFinite');
  7. // https://tc39.es/ecma262/#sec-isintegralnumber
  8. module.exports = function IsIntegralNumber(argument) {
  9. if (Type(argument) !== 'Number' || $isNaN(argument) || !$isFinite(argument)) {
  10. return false;
  11. }
  12. var absValue = abs(argument);
  13. return floor(absValue) === absValue;
  14. };