xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

empty Checker

empty Checker


"use strict";

/**
 *
 * @author xgqfrms
 * @license MIT
 * @copyright xgqfrms
 *
 * @description Utils & emptyChecker();
 * @augments
 * @example
 *
 * @param {String} key
 * @param {Boolean} debug
 */

const emptyChecker = (key = ``, debug = false) => {
    let result = true,
        strKey = `${key}`;
    switch (strKey) {
        case "undefined":
            result = false;
            break;
        case "null":
            result = false;
            break;
        case "":
            result = false;
            break;
        case "--":
            result = false;
            break;
        // case "0":
        //     result = false;
        //     break;
        case -1.7976931348623157e+308:
            result = false;
            break;
        default:
            break;
    }
    if (debug) {
        console.log(`key =`, key);
        console.log(`strKey =`, strKey);
        console.log(`result =`, result);
    }
    return result;
};


export default emptyChecker;

export {
    emptyChecker
};


posted @ 2019-05-17 15:25  xgqfrms  阅读(179)  评论(1编辑  收藏  举报