提交 2a12c9a4 编写于 作者: J Johannes Rieken

add es6 deprecation messages to some utils, remove duplicated utils,...

add es6 deprecation messages to some utils, remove duplicated utils, https://github.com/microsoft/vscode/issues/90676
上级 4f2ea532
......@@ -14,7 +14,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { ITreeModel, ITreeNode, ITreeRenderer, ITreeEvent, ITreeMouseEvent, ITreeContextMenuEvent, ITreeFilter, ITreeNavigator, ICollapseStateChangeEvent, ITreeDragAndDrop, TreeDragOverBubble, TreeVisibility, TreeFilterResult, ITreeModelSpliceEvent, TreeMouseEventTarget } from 'vs/base/browser/ui/tree/tree';
import { ISpliceable } from 'vs/base/common/sequence';
import { IDragAndDropData, StaticDND, DragAndDropData } from 'vs/base/browser/dnd';
import { range, equals, distinctES6, fromSet } from 'vs/base/common/arrays';
import { range, equals, distinctES6 } from 'vs/base/common/arrays';
import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView';
import { domEvent } from 'vs/base/browser/event';
import { fuzzyScore, FuzzyScore } from 'vs/base/common/filters';
......@@ -1320,7 +1320,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
set.add(node);
}
return fromSet(set);
return values(set);
}).event;
if (_options.keyboardSupport !== false) {
......
......@@ -372,12 +372,6 @@ export function distinctES6<T>(array: ReadonlyArray<T>): T[] {
});
}
export function fromSet<T>(set: Set<T>): T[] {
const result: T[] = [];
set.forEach(o => result.push(o));
return result;
}
export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
const seen: { [key: string]: boolean; } = Object.create(null);
......@@ -405,6 +399,9 @@ export function lastIndex<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean):
return -1;
}
/**
* @deprecated ES6: use `Array.findIndex`
*/
export function firstIndex<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): number {
for (let i = 0; i < array.length; i++) {
const element = array[i];
......@@ -417,6 +414,10 @@ export function firstIndex<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean)
return -1;
}
/**
* @deprecated ES6: use `Array.find`
*/
export function first<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean, notFoundValue: T): T;
export function first<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): T | undefined;
export function first<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean, notFoundValue: T | undefined = undefined): T | undefined {
......@@ -471,6 +472,9 @@ export function range(arg: number, to?: number): number[] {
return result;
}
/**
* @deprecated ES6: use `Array.fill`
*/
export function fill<T>(num: number, value: T, arr: T[] = []): T[] {
for (let i = 0; i < num; i++) {
arr[i] = value;
......@@ -564,6 +568,10 @@ export function pushToEnd<T>(arr: T[], value: T): void {
}
}
/**
* @deprecated ES6: use `Array.find`
*/
export function find<T>(arr: ArrayLike<T>, predicate: (value: T, index: number, arr: ArrayLike<T>) => any): T | undefined {
for (let i = 0; i < arr.length; i++) {
const element = arr[i];
......
......@@ -95,11 +95,6 @@ export function fromMap<T>(original: Map<string, T>): IStringDictionary<T> {
return result;
}
export function mapValues<V>(map: Map<any, V>): V[] {
const result: V[] = [];
map.forEach(v => result.push(v));
return result;
}
export class SetMap<K, V> {
......
......@@ -7,7 +7,9 @@ import { URI } from 'vs/base/common/uri';
import { CharCode } from 'vs/base/common/charCode';
import { Iterator, IteratorResult, FIN } from './iterator';
/**
* @deprecated ES6: use `[...SetOrMap.values()]`
*/
export function values<V = any>(set: Set<V>): V[];
export function values<K = any, V = any>(map: Map<K, V>): V[];
export function values<V>(forEachable: { forEach(callback: (value: V, ...more: any[]) => any): void }): V[] {
......@@ -16,6 +18,9 @@ export function values<V>(forEachable: { forEach(callback: (value: V, ...more: a
return result;
}
/**
* @deprecated ES6: use `[...map.keys()]`
*/
export function keys<K, V>(map: Map<K, V>): K[] {
const result: K[] = [];
map.forEach((_value, key) => result.push(key));
......@@ -51,6 +56,9 @@ export function setToString<K>(set: Set<K>): string {
return `Set(${set.size}) {${entries.join(', ')}}`;
}
/**
* @deprecated ES6: use `...Map.entries()`
*/
export function mapToSerializable(map: Map<string, string>): [string, string][] {
const serializable: [string, string][] = [];
......@@ -61,6 +69,9 @@ export function mapToSerializable(map: Map<string, string>): [string, string][]
return serializable;
}
/**
* @deprecated ES6: use `new Map([[key1, value1],[key2, value2]])`
*/
export function serializableToMap(serializable: [string, string][]): Map<string, string> {
const items = new Map<string, string>();
......
......@@ -8,8 +8,7 @@ import * as paths from 'vs/base/common/path';
import { Iterator } from 'vs/base/common/iterator';
import { relativePath, joinPath } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { mapValues } from 'vs/base/common/collections';
import { PathIterator } from 'vs/base/common/map';
import { PathIterator, values } from 'vs/base/common/map';
export interface IResourceNode<T, C = void> {
readonly uri: URI;
......@@ -32,7 +31,7 @@ class Node<T, C> implements IResourceNode<T, C> {
}
get children(): Iterator<Node<T, C>> {
return Iterator.fromArray(mapValues(this._children));
return Iterator.fromArray(values(this._children));
}
@memoize
......
......@@ -15,7 +15,7 @@ export function isFalsyOrWhitespace(str: string | undefined): boolean {
}
/**
* @returns the provided number with the given number of preceding zeros.
* @deprecated ES6: use `String.padStart`
*/
export function pad(n: number, l: number, char: string = '0'): string {
const str = '' + n;
......@@ -146,7 +146,7 @@ export function stripWildcards(pattern: string): string {
}
/**
* Determines if haystack starts with needle.
* @deprecated ES6: use `String.startsWith`
*/
export function startsWith(haystack: string, needle: string): boolean {
if (haystack.length < needle.length) {
......@@ -167,7 +167,7 @@ export function startsWith(haystack: string, needle: string): boolean {
}
/**
* Determines if haystack ends with needle.
* @deprecated ES6: use `String.endsWith`
*/
export function endsWith(haystack: string, needle: string): boolean {
const diff = haystack.length - needle.length;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册