Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: Morgan Vernay <morgan@cal.com> Co-authored-by: Omar López <zomars@me.com>
7 lines
311 B
TypeScript
7 lines
311 B
TypeScript
export const notUndefined = <T>(val: T | undefined): val is T => Boolean(val);
|
|
export const uniqueBy = <T extends { [key: string]: unknown }>(array: T[], keys: (keyof T)[]) => {
|
|
return array.filter(
|
|
(item, index, self) => index === self.findIndex((t) => keys.every((key) => t[key] === item[key]))
|
|
);
|
|
};
|