index.js 507 B

123456789101112131415161718192021
  1. /*!
  2. * is-number <https://github.com/jonschlinkert/is-number>
  3. *
  4. * Copyright (c) 2014-2017, Jon Schlinkert.
  5. * Released under the MIT License.
  6. */
  7. 'use strict';
  8. module.exports = function isNumber(num) {
  9. var type = typeof num;
  10. if (type === 'string' || num instanceof String) {
  11. // an empty string would be coerced to true with the below logic
  12. if (!num.trim()) return false;
  13. } else if (type !== 'number' && !(num instanceof Number)) {
  14. return false;
  15. }
  16. return (num - num + 1) >= 0;
  17. };