IsInteger.js 450 B

1234567891011121314151617
  1. 'use strict';
  2. var abs = require('./abs');
  3. var floor = require('./floor');
  4. var $isNaN = require('../helpers/isNaN');
  5. var $isFinite = require('../helpers/isFinite');
  6. // https://ecma-international.org/ecma-262/6.0/#sec-isinteger
  7. module.exports = function IsInteger(argument) {
  8. if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
  9. return false;
  10. }
  11. var absValue = abs(argument);
  12. return floor(absValue) === absValue;
  13. };