mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 01:25:42 -05:00
Adds experimental support for Open in GitHub
This commit is contained in:
14
src/system/array.ts
Normal file
14
src/system/array.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
export namespace Arrays {
|
||||
export function uniqueBy<T>(array: T[], accessor: (item: T) => any, predicate?: (item: T) => boolean): T[] {
|
||||
const uniqueValues = Object.create(null);
|
||||
return array.filter(_ => {
|
||||
const value = accessor(_);
|
||||
if (uniqueValues[value]) return false;
|
||||
|
||||
uniqueValues[value] = accessor;
|
||||
return predicate ? predicate(_) : true;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user