Skip to content

Commit

Permalink
make menusExtensionPoint.ts easier to edit
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Jul 23, 2020
1 parent 28d97ae commit c3cef6f
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 197 deletions.
7 changes: 3 additions & 4 deletions src/vs/base/common/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,10 @@ export function range(arg: number, to?: number): number[] {
}

export function index<T>(array: ReadonlyArray<T>, indexer: (t: T) => string): { [key: string]: T; };
export function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, merger?: (t: T, r: R) => R): { [key: string]: R; };
export function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, merger: (t: T, r: R) => R = t => t as any): { [key: string]: R; } {
export function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper: (t: T) => R): { [key: string]: R; };
export function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper?: (t: T) => R): { [key: string]: R; } {
return array.reduce((r, t) => {
const key = indexer(t);
r[key] = merger(t, r[key]);
r[indexer(t)] = mapper ? mapper(t) : t;
return r;
}, Object.create(null));
}
Expand Down
Loading

0 comments on commit c3cef6f

Please sign in to comment.