Typescript filter duplicates

Date: 2019-06-27
const unique = (arr: any[], valFn: (item) => any) => {
    const values = {};
    return arr.filter(item => {
        const val = String(valFn(item));
        return val in values ? false : values[val] = true;
    });
};
// unique(data, d => d.id)
22870cookie-checkTypescript filter duplicates