/**
 * @since Last modified: 2024-01-19 12:58:58
 * @function requireTypes
 * @description It is required to use specific data types. If the data is not a specified type, the error will be reported and the execution will be terminated.
 * @param {*} data  - Any type data.
 * @param {array} require  - The required format array, if a type is required, you can fill in the string.Optional values are:Array,Object,Function,String,Number,Boolean,Date,Symbol,Null,Undefined,Element(not case sensitive)
 * @param {function} [cb]  - Callback,Support a parameter:error.
 * @returns {undefined} - Return nothing.
 * @see {@link https://codepen.io/axui/pen/JjxNQJM|demo @ codepen}
 * @example
 * requireTypes('123',['number','array']);
 * <!--return a uncatch error & terminate -->
 */
'use strict';
import getDataType from './getDataType';
const requireTypes = (data, require, cb) => {
    let type = getDataType(data).toLowerCase(), types = typeof require === 'string' ? [require] : require;
    type.includes('html') ? type = 'element' : null;
    types = types.map((k) => k.toLowerCase());
    if (cb) {
        try {
            if (!types.includes(type)) {
                throw new Error(`Wrong data type,Require types: "${'' + types}"!`);
            }
        }
        catch (error) {
            cb(error);
        }
    }
    else {
        if (!types.includes(type)) {
            throw new Error(`Wrong data type,Require types: "${'' + types}"!`);
        }
    }
};
export default requireTypes;
