Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MakeUnique
function makeUnique<T>(arr: T[], idSelector: (e: T) => string | number) {
const obj = {};
arr.forEach(e => {
obj[idSelector(e)] = e;
});
return Object.keys(obj).map(key => obj[key]) as T[];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment