Created
November 22, 2019 00:20
-
-
Save JonathonAshworth/75aa15a32fd0beebe32a517484383550 to your computer and use it in GitHub Desktop.
Array unique filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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