/**
 * @since Last modified: 2024-08-04 17:31:32
 * @function unique
 * @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.unique([0,11,22,11,12]);
 * <!--Return [0,11,22,12]-->
 */
'use strict';
import isEmpty from "./isEmpty";
const unique = (data, prop) => {
    let result;
    if (!isEmpty(data)) {
        result = [...new Set(data)];
        if (typeof result[0] === 'object' && prop) {
            let map = new Map();
            for (let k of result) {
                !map.has(k[prop]) && map.set(k[prop], k);
            }
            result = [...map.values()];
        }
    }
    else {
        result = [...data];
    }
    return result;
};
export default unique;
