/**
 * @since Last modified: 2023-11-18 13:39:43
 * @function attrToJson
 * @description Merge the multiple attribute values of the node into JSON.
 * @param {getEl} elem  - Target node or node selector, please refer to the util : getEl.
 * @param {string} attr  - Node attribute.
 * @returns {Object|{}} - Return a json.
 * @see {@link https://codepen.io/axui/pen/rNPmEqz|demo @ codepen}
 * @example
 * <div ax="a:0,b:1"></div>
 * attrToJson('#demo', 'ax');
 * <!--return {a:0,b:1}-->
 */
'use strict';
import getEl from './getEl';
import requireTypes from './requireTypes';
import attrToJson from './attrToJson';
const attrsToJson = (elem: any, attrs: string[], refer?: string[]) => {
    requireTypes(attrs, 'array');
    requireTypes(refer, 'array');
    let dom = getEl(elem),
        json = {},
        options = {};
    attrs.map((k: string, i: number) => {
        let key = refer && refer[i] ? refer[i] : k;
        if (key === 'options') {
            options = attrToJson(dom, k)
        } else {
            json[key] = attrToJson(dom, k);
        }
    });
    return Object.assign(options, json);
}
export default attrsToJson;
