UNPKG

diginext-utils

Version:
18 lines 685 B
/** * Creates an array of unique values from one or more arrays. * If a key is provided, uniqueness is determined by that property. * * @template T - The type of elements in the arrays * @param arrays - One or more arrays to combine and make unique * @param key - Optional key to determine uniqueness for objects * @returns A new array with unique values * * @example * ```ts * unique([1, 2, 2, 3, 3, 4]); // [1, 2, 3, 4] * unique([1, 2], [2, 3], [3, 4]); // [1, 2, 3, 4] * unique([{ id: 1 }, { id: 1 }, { id: 2 }], 'id'); // [{ id: 1 }, { id: 2 }] * ``` */ export declare function unique<T>(arrays: T[] | T[][], key?: keyof T): T[]; //# sourceMappingURL=unique.d.ts.map