Basic usage

Given an array of items — and optionally, a function to determine their identity — return a new array without any duplicates.

import { unique } from 'radash'

const fish = [{
  name: 'Marlin',
  weight: 105,
  source: 'ocean'
}, {
  name: 'Salmon',
  weight: 22,
  source: 'river'
}, {
  name: 'Salmon',
  weight: 22,
  source: 'river'
}]

unique(fish, f => f.name) // => [marlin, salmon]

Testing

This _.unique function is 100% covered by tests. See them and contribute at GitHub.

Source

See the source for _.unique on GitHub.