/**
 * @since Last modified: 2023-11-20 17:53:19
 * @function attrJoinValue
 * @param {string} attr  - one attribute of element.
 * @param {string} value  - The value corresponding to the attribute.
 * @param {array} map  - The options map.
 * @returns {Object} - Return a object.
 * @see {@link https://codepen.io/axui/pen/KKJQRwG|demo @ codepen}
 * @example
 * ax.attrJoinValue('length','30');
 * <!--return {length:30}-->
 */
'use strict';
const attrJoinValue = (attr: string, value: string, map?: T_obj[]) => {
    try {
        if (map) {
            let item: any = map.find((k: any) => k.attr === attr);
            if (item) {
                return (typeof item.value === 'string') ? { [item.prop]: value } :
                    (typeof item.value === 'boolean' && value === '') ? { [item.propr]: true } :
                        new Function('return ' + `{${item.prop}:${value}}`)();
            }
        } else {
            return value === '' ? { [attr]: '' } : new Function('return ' + `{${attr}:${value}}`)();
        }
    } catch {
        return { [attr]: value };
    }
}
export default attrJoinValue;
