isInteger.js 440 B

123456789101112131415161718
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $abs = GetIntrinsic('%Math.abs%');
  4. var $floor = GetIntrinsic('%Math.floor%');
  5. var $isNaN = require('./isNaN');
  6. var $isFinite = require('./isFinite');
  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. };