/**
 * @since Last modified: 2024/06/25 10:06:36
 * @function findItems
 * @description Operate on the ax propperty of the node.
 * @param {number|string|HTMLElement|object} val  - Find item's search value.
 * @param {object[]} source  - Data sources.
 * @returns {undefined|object} - Return the search result.
 * @see {@link https://codepen.io/axui/pen/qBGKmKP|demo @ codepen}
 * @example
 * ax.findItems(0,[{a:0},{b:1}]);
 * <!--return {a:0}-->
 */




'use strict';
import { T_obj } from '../../../types/ax';
import { T_find_item } from '../../../types/utils';
import findItem from './findItem';
import getDataType from './getDataType';

const findItems = (vals: T_find_item | T_find_item[], source: T_obj[], key?: string): any[] => {
    let valsType = getDataType(vals),
        result: any[] = [],
        tmp = (valsType === 'String') ? vals.split(',') :
            (valsType === 'Array') ? vals : [vals];
    result = tmp.map((k: any) => findItem(k, source, key)).filter(Boolean);
    return result;
}
export default findItems;
