param arr param kFn returns export function uniqueBy < T , K > ( arr , kFn = ( v ) => v as any ) { const set = new Set < K > ( ) ; return arr . filter ( ( v , ... args ) => { const k = kFn ( v , ... args ) ; if ( set . has ( k ) ) { return false ; } set . add ( k ) ; return true ; } ) ; }