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