Distinct Array Items
An easy, elegant way to get distinct (unique) values of an array using Set (ES6 only).
export function distinctItems<T>(items: Array<T>) {
return [...new Set(items)];
}
Usage
const items = ["a", "b", "c", "a", "d"];
const distinct = distinctItems(items); // ["a", "b", "c", "d"]