'use strict';

/**
 * 判断一个变量是否为数值
 * @param {any} value 需要判断的值
 * @param {boolean} isLoose 是否可包含NaN或无限
 * @returns {boolean}
 *
 * isNum(999);             // => true;
 * isNum(0.1);             // => true;
 * isNum(NaN);             // => false;
 * isNum(NaN, true);       // => true;
 * isNum(Infinity);        // => false;
 * isNum(Infinity, true);  // => true;
 * isNum('abc');           // => false;
 * isNum('abc', true);     // => false;
 */
function isNum(value, isLoose) {
  var isNumType = typeof value === 'number';
  if (isLoose) return isNumType;
  return isNumType && !Number.isNaN(value) && Number.isFinite(value);
}

module.exports = isNum;
