rxjs
Version:
Reactive Extensions for modern JavaScript
13 lines • 519 B
JavaScript
import { operate } from '../util/lift';
import { OperatorSubscriber } from './OperatorSubscriber';
export function takeWhile(predicate, inclusive = false) {
return operate((source, subscriber) => {
let index = 0;
source.subscribe(new OperatorSubscriber(subscriber, (value) => {
const result = predicate(value, index++);
(result || inclusive) && subscriber.next(value);
!result && subscriber.complete();
}));
});
}
//# sourceMappingURL=takeWhile.js.map