/**
 * @since Last modified: 2023-11-15 18:30:56
 * @function isEmpty
 * @description Determine whether it is empty data.The data itself is empty data: 0| ''|false|undefined|null; <br>empty function: function () {}|() => {}; <br>empty array and empty objects: []|{}| [null]| [ undefined]| ['']| [""];<br> empty symbol object: symbol()|symbol.For(), will be judged as empty.
 * @param {*} data  - Can be any data
 * @returns {boolean}  - Return true or false
 * @see {@link https://codepen.io/axui/pen/OJdXdxM|demo @ codepen}
 * @example
 * ax.isEmpty([null]);
 * <!--return true-->
 */
'use strict';
import getDataType from './getDataType';
const isEmpty = (data: any): boolean => {
    let type = getDataType(data), flag: boolean;
    if (!data) {
        flag = true;
    } else {
        flag = (type === 'Object') ? (Object.keys(data).length === 0) :
            (type === 'Array') ? data.join('') === '' :
                (type === 'Function') ? (data.toString().replace(/\s+/g, '').match(/{.*}/g)[0] === '{}') :
                    (type === 'Symbol') ? (data.toString().replace(/\s+/g, '').match(/\(.*\)/g)[0] === '()') : false;
    }
    return flag;
}
export default isEmpty;
