/**
 * @since Last modified: 2024-01-18 12:28:03
 * @constant spreadParams
 * @description Expand the parameters of "true" into a real default parameters.Support infinite depth.
 * @param {object} host  - The host options.
 * @param {object} params  - default parameters.
 * @returns {object} - The host options expanded.
 * @see {@link https://codepen.io/axui/pen/RwvmpJG|demo @ codepen}
 * @example
 * ax.spreadParams(options,{a:{},b:{}});
 * <!--options.a=true,options.b=true -> options.a={},options.b={}-->
 * ax.spreadParams(options,{a:[],b:{}});
 * <!--options.a=false,options.b=false -> options.a=false,options.b={enable:false}-->
 */
'use strict';
import getDataType from "./getDataType";
const spreadParams = (host: any, params: T_obj) => {
    for (let k in params) {
        if (params.hasOwnProperty(k) && host.hasOwnProperty(k)) {
            let hostType = getDataType(host[k]);
            if (hostType === 'Object') {
                spreadParams(host[k], params[k])
            } else {
                host[k] === true ? host[k] = { enable: true, ...params[k] } :
                    host[k] === false && getDataType(params[k]) === 'Object' ? host[k] = { enable: false, ...params[k] } : null;
            }
        }
    }
    return host;
}
export default spreadParams;
