/**
 * @since Last modified: 2024/04/20 14:46:26
 * @function dlToArr
 * @description One-dimensional array deduplication.
 * @param {array} data - The array data.
 * @param {string} [prop] - The property specified by the deduplication operation.
 * @returns  {array} - The new array after removing duplicates.
 * @see {@link https://codepen.io/axui/pen/YzgZwRO|demo @ codepen}
 * @example
 * ax.dlToArr([0,11,22,11,12]);
 * <!--Return [0,11,22,12]-->
 */
'use strict';
import getEl from "./getEl";
import getValsFromAttrs from './getValsFromAttrs';
const dlToArr = (el) => {
    let elem = getEl(el), result = [];
    if (!elem) {
        console.warn(`No node, no access to data!`);
        return result;
    }
    let heads = [...elem.querySelectorAll('dt')], bodys = [...elem.querySelectorAll('dd')];
    if (heads.length !== bodys.length) {
        console.warn('Inconsistent number of "dt" and "dd" tags!');
        return result;
    }
    if (heads.length === 0) {
        console.warn('No "dt" and "dd" tags!');
        return result;
    }
    result = heads.map((k, i) => {
        return { content: bodys[i].innerHTML, ...getValsFromAttrs(k) };
    });
    return result;
};
export default dlToArr;
