提交 d2bc3a07 编写于 作者: J Johannes Rieken

remove unused and duplicated code

上级 66bcd337
......@@ -71,18 +71,6 @@ export function forEach<T>(from: IStringDictionary<T> | INumberDictionary<T>, ca
}
}
/**
* Removes an element from the dictionary. Returns {{false}} if the property
* does not exists.
*/
export function remove<T>(from: IStringDictionary<T> | INumberDictionary<T>, key: string): boolean {
if (!hasOwnProperty.call(from, key)) {
return false;
}
delete (from as any)[key];
return true;
}
/**
* Groups the collection into a dictionary based on the provided
* group function.
......
......@@ -171,7 +171,7 @@ export function equals(one: any, other: any): boolean {
return true;
}
export function arrayToHash(array: any[]) {
function arrayToHash(array: string[]): { [name: string]: true } {
const result: any = {};
for (let i = 0; i < array.length; ++i) {
result[array[i]] = true;
......@@ -218,11 +218,6 @@ export function safeStringify(obj: any): string {
});
}
export function getOrDefault<T, R>(obj: T, fn: (obj: T) => R, defaultValue: R | null = null): R | null {
const result = fn(obj);
return typeof result === 'undefined' ? defaultValue : result;
}
export function getOrDefault2<T, R>(obj: T, fn: (obj: T) => R | undefined, defaultValue: R): R {
const result = fn(obj);
return typeof result === 'undefined' ? defaultValue : result;
......
......@@ -54,9 +54,4 @@ suite('Collections', () => {
assert.equal(grouped[group2].length, 1);
assert.equal(grouped[group2][0].value, value3);
});
test('remove', () => {
assert(collections.remove({ 'far': 1 }, 'far'));
assert(!collections.remove({ 'far': 1 }, 'boo'));
});
});
......@@ -9,7 +9,7 @@ import { distinct } from 'vs/base/common/arrays';
import { getErrorMessage, isPromiseCanceledError, canceled } from 'vs/base/common/errors';
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionManifest, IExtensionIdentifier, IReportedExtension, InstallOperation, ITranslation } from 'vs/platform/extensionManagement/common/extensionManagement';
import { getGalleryExtensionId, getGalleryExtensionTelemetryData, adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { assign, getOrDefault } from 'vs/base/common/objects';
import { assign, getOrDefault2 } from 'vs/base/common/objects';
import { IRequestService } from 'vs/platform/request/node/request';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPager } from 'vs/base/common/paging';
......@@ -402,7 +402,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
const type = options.names ? 'ids' : (options.text ? 'text' : 'all');
let text = options.text || '';
const pageSize = getOrDefault(options, o => o.pageSize, 50);
const pageSize = getOrDefault2(options, o => o.pageSize, 50);
/* __GDPR__
"galleryService:query" : {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册