Skip to content

Instantly share code, notes, and snippets.

@ztrehagem
Created June 21, 2023 07:34
Show Gist options
  • Save ztrehagem/cb6949d3c155a9165b0fa84f7eeeb5fe to your computer and use it in GitHub Desktop.
Save ztrehagem/cb6949d3c155a9165b0fa84f7eeeb5fe to your computer and use it in GitHub Desktop.
export const uniqueArray = <E>(
array: readonly E[],
isEqual: (a: E, b: E) => boolean = Object.is
): E[] => {
return array.filter(
(a, index, self) => index == self.findIndex((b) => isEqual(a, b))
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment