{"size": 779, "ext": "js", "max_stars_repo_path": "src/abc-util-getType.js", "max_stars_repo_name": "abensu/node-ab-ccss", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/abc-util-getType.js", "max_issues_repo_name": "abensu/node-ab-ccss", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/abc-util-getType.js", "max_forks_repo_name": "abensu/node-ab-ccss", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.9666666667, "max_line_length": 110, "alphanum_fraction": 0.377406932}
﻿/**
 * 获得数据类型
 *
 * @param {*} data  : [] 待判定类型的数据
 *
 * @return {string} : [] 类型数据
 *                      |- "string"
 *                      |- "number"
 *                      |- "regexp"
 *                      |- "array"
 *                      |- "function"
 *                      |- "nan"
 *                      |- "null"
 *                      |- "undefined"
 *                      `- "object"
 */

exports.getType = function(data) {

    var _type = Object.prototype.toString.call(data).replace(/(^\[object\s)|(]$)/ig, "").toLocaleLowerCase();

    // 由于 NaN 和普通数字都返回 number，所以对 number 要再作判定
    // 先判定是否为 number，是因为 isNaN("NaN") 会返回 true
    if (_type === "number" && isNaN(data)) {

        _type = "nan";
    }

    return _type;
};