You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
252 B

2 months ago
  1. export default function uniqueBy(arr, fn) {
  2. var identifiers = new Set();
  3. return arr.filter(function (item) {
  4. var identifier = fn(item);
  5. if (!identifiers.has(identifier)) {
  6. identifiers.add(identifier);
  7. return true;
  8. }
  9. });
  10. }