Skip to content

Instantly share code, notes, and snippets.

@JonathonAshworth
Created November 22, 2019 00:20
Show Gist options
  • Save JonathonAshworth/75aa15a32fd0beebe32a517484383550 to your computer and use it in GitHub Desktop.
Save JonathonAshworth/75aa15a32fd0beebe32a517484383550 to your computer and use it in GitHub Desktop.
Array unique filter
export const unique = (arr, eq) => arr.reduce(
(acc, item) => (eq ? acc.find(a => eq(a, item)) !== undefined : acc.includes(item))
? acc
: [...acc, item]
, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment