Debian Codegraph @

node/rxjs/dist/esm/internal/operators/find.js

raw
1 import { operate } from '../util/lift';
2 import { createOperatorSubscriber } from './OperatorSubscriber';
3 export function find(predicate, thisArg) {
4 return operate(createFind(predicate, thisArg, 'value'));
5 }
6 export function createFind(predicate, thisArg, emit) {
7 const findIndex = emit === 'index';
8 return (source, subscriber) => {
9 let index = 0;
10 source.subscribe(createOperatorSubscriber(subscriber, (value) => {
11 const i = index++;
12 if (predicate.call(thisArg, value, i, source)) {
13 subscriber.next(findIndex ? i : value);
14 subscriber.complete();
15 }
16 }, () => {
17 subscriber.next(findIndex ? -1 : undefined);
18 subscriber.complete();
19 }));
20 };
21 }
22 //# sourceMappingURL=find.js.map