hugoWebsite/node_modules/rxjs/dist/esm/internal/operators/takeWhile.js

13 lines
527 B
JavaScript
Raw Normal View History

2022-10-29 00:20:35 +02:00
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function takeWhile(predicate, inclusive = false) {
return operate((source, subscriber) => {
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const result = predicate(value, index++);
(result || inclusive) && subscriber.next(value);
!result && subscriber.complete();
}));
});
}
//# sourceMappingURL=takeWhile.js.map