All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.lib.utils.uniqueBy.js.flow Maven / Gradle / Ivy

There is a newer version: 2.11.8
Show newest version
// @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