UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

20 lines 872 B
/** * Returns a new array containing only one copy of each element in the original list transformed by a function. * Elements are compared by reference using Set. * @param array - List of items * @signature * P.uniqBy(fn, array) * @signature * P.pipe(array, P.uniqBy(fn)) * @example * P.uniq(obj => obj.n, [{n: 1}, {n: 2}, {n: 2}, {n: 5}, {n: 1}, {n: 6}, {n: 7}]) // => [{n: 1}, {n: 2}, {n: 5}, {n: 6}, {n: 7}] * P.pipe( * [{n: 1}, {n: 2}, {n: 2}, {n: 5}, {n: 1}, {n: 6}, {n: 7}], // only 4 iterations * P.uniq(obj => obj.n), * P.take(3) * ) // => [{n: 1}, {n: 2}, {n: 5}] * @category Array, Pipe */ export declare function uniqBy<T, K>(array: readonly T[], transformer: (item: T) => K): T[]; export declare function uniqBy<T, K>(transformer: (item: T) => K): (array: readonly T[]) => T[]; //# sourceMappingURL=uniqBy.d.ts.map