UNPKG

@patternfly/react-core

Version:

This library provides a set of common React components for use with the PatternFly reference implementation.

19 lines (15 loc) 332 B
// @ts-nocheck /** * @param arr * @param fn */ export default function uniqueBy<T>(arr: T[], fn: (arg0: T) => any): T[] { const identifiers = new Set(); return arr.filter(item => { const identifier = fn(item); if (!identifiers.has(identifier)) { identifiers.add(identifier); return true; } }); }