mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 09:35:37 -05:00
Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae
This commit is contained in:
committed by
AzureDataStudio
parent
a971aee5bd
commit
5e7071e466
28
extensions/github-browser/src/iterables.ts
Normal file
28
extensions/github-browser/src/iterables.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export namespace Iterables {
|
||||
export function* filterMap<T, TMapped>(
|
||||
source: Iterable<T> | IterableIterator<T>,
|
||||
predicateMapper: (item: T) => TMapped | undefined | null,
|
||||
): Iterable<TMapped> {
|
||||
for (const item of source) {
|
||||
const mapped = predicateMapper(item);
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (mapped != null) { yield mapped; }
|
||||
}
|
||||
}
|
||||
|
||||
export function* map<T, TMapped>(
|
||||
source: Iterable<T> | IterableIterator<T>,
|
||||
mapper: (item: T) => TMapped,
|
||||
): Iterable<TMapped> {
|
||||
for (const item of source) {
|
||||
yield mapper(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user