puppeteer/packages/puppeteer-core/third_party/rxjs/rxjs.ts
2024-01-03 10:11:33 +00:00

59 lines
895 B
TypeScript

/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {
bufferCount,
catchError,
concatMap,
defaultIfEmpty,
defer,
delay,
EMPTY,
filter,
first,
firstValueFrom,
forkJoin,
from,
fromEvent,
identity,
ignoreElements,
lastValueFrom,
map,
merge,
mergeMap,
NEVER,
noop,
of,
pipe,
race,
raceWith,
retry,
startWith,
switchMap,
takeUntil,
tap,
throwIfEmpty,
timer,
} from 'rxjs';
export type * from 'rxjs';
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;
})
);
});
}