Use Array.flat() (#110189)

This commit is contained in:
David Sanders 2020-11-09 12:46:26 -08:00 committed by GitHub
parent e300dfcdd2
commit fcef0e3db4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 8 deletions

View file

@ -7,7 +7,6 @@ import { Token } from 'markdown-it';
import * as vscode from 'vscode';
import { MarkdownEngine } from '../markdownEngine';
import { TableOfContentsProvider } from '../tableOfContentsProvider';
import { flatten } from '../util/arrays';
const rangeLimit = 5000;
@ -27,7 +26,7 @@ export default class MarkdownFoldingProvider implements vscode.FoldingRangeProvi
this.getHeaderFoldingRanges(document),
this.getBlockFoldingRanges(document)
]);
return flatten(foldables).slice(0, rangeLimit);
return foldables.flat().slice(0, rangeLimit);
}
private async getRegions(document: vscode.TextDocument): Promise<vscode.FoldingRange[]> {

View file

@ -9,7 +9,6 @@ import { isMarkdownFile } from '../util/file';
import { Lazy, lazy } from '../util/lazy';
import MDDocumentSymbolProvider from './documentSymbolProvider';
import { SkinnyTextDocument, SkinnyTextLine } from '../tableOfContentsProvider';
import { flatten } from '../util/arrays';
export interface WorkspaceMarkdownDocumentProvider {
getAllMarkdownDocuments(): Thenable<Iterable<SkinnyTextDocument>>;
@ -136,7 +135,7 @@ export default class MarkdownWorkspaceSymbolProvider extends Disposable implemen
}
const allSymbolsSets = await Promise.all(Array.from(this._symbolCache.values()).map(x => x.value));
const allSymbols = flatten(allSymbolsSets);
const allSymbols = allSymbolsSets.flat();
return allSymbols.filter(symbolInformation => symbolInformation.name.toLowerCase().indexOf(query.toLowerCase()) !== -1);
}

View file

@ -15,8 +15,4 @@ export function equals<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, itemEq
}
return true;
}
export function flatten<T>(arr: ReadonlyArray<T>[]): T[] {
return ([] as T[]).concat.apply([], arr);
}

View file

@ -6,6 +6,7 @@
"lib": [
"es6",
"es2015.promise",
"es2019.array",
"es2020.string",
"dom"
]