
package.lib.utils.uniqueBy.js.flow Maven / Gradle / Ivy
// @flow
export default function uniqueBy(arr: Array, fn: T => any): Array {
const identifiers = new Set();
return arr.filter(item => {
const identifier = fn(item);
if (!identifiers.has(identifier)) {
identifiers.add(identifier);
return true;
}
});
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy