Skip to content

Instantly share code, notes, and snippets.

@jgimbel
Created June 27, 2017 18:18
Show Gist options
  • Save jgimbel/b2abd5b38c5f930f513867aa2b352508 to your computer and use it in GitHub Desktop.
Save jgimbel/b2abd5b38c5f930f513867aa2b352508 to your computer and use it in GitHub Desktop.
function unique(arr, func) {
const uniques = arr.reduce((o, k) => func(k) in o ? o : Object.assign(o, {[func(k)]: k}), {})
return Object.keys(uniques).map(k => uniques[k])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment