isFinite.js 480 B

123456789101112131415161718192021
  1. var isNumber = require('./isNumber');
  2. var global = this;
  3. /**
  4. * Check if value is finite
  5. */
  6. function isFinite(val){
  7. var is = false;
  8. if (typeof val === 'string' && val !== '') {
  9. is = global.isFinite( parseFloat(val) );
  10. } else if (isNumber(val)){
  11. // need to use isNumber because of Number constructor
  12. is = global.isFinite( val );
  13. }
  14. return is;
  15. }
  16. module.exports = isFinite;