puppeteer/packages/puppeteer-core/third_party/rxjs/rxjs.ts

60 lines
909 B
TypeScript
Raw Normal View History

/**
2024-01-03 10:11:33 +00:00
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {
2023-10-06 14:50:39 +00:00
bufferCount,
catchError,
2023-10-06 14:50:39 +00:00
concatMap,
defaultIfEmpty,
defer,
delay,
EMPTY,
filter,
first,
firstValueFrom,
forkJoin,
from,
fromEvent,
identity,
ignoreElements,
2023-10-06 14:50:39 +00:00
lastValueFrom,
map,
merge,
mergeMap,
NEVER,
noop,
Observable,
of,
pipe,
race,
raceWith,
retry,
startWith,
switchMap,
2023-10-06 14:50:39 +00:00
takeUntil,
tap,
throwIfEmpty,
timer,
} from 'rxjs';
export type * from 'rxjs';
2023-10-06 14:50:39 +00:00
import {filter, from, map, mergeMap, type Observable} from 'rxjs';
export function filterAsync<T>(
predicate: (value: T) => boolean | PromiseLike<boolean>
) {
return mergeMap<T, Observable<T>>(value => {
return from(Promise.resolve(predicate(value))).pipe(
filter(isMatch => {
return isMatch;
}),
map(() => {
return value;
})
);
});
}