takeWhile.js 527 B

12345678910111213
  1. import { operate } from '../util/lift';
  2. import { createOperatorSubscriber } from './OperatorSubscriber';
  3. export function takeWhile(predicate, inclusive = false) {
  4. return operate((source, subscriber) => {
  5. let index = 0;
  6. source.subscribe(createOperatorSubscriber(subscriber, (value) => {
  7. const result = predicate(value, index++);
  8. (result || inclusive) && subscriber.next(value);
  9. !result && subscriber.complete();
  10. }));
  11. });
  12. }
  13. //# sourceMappingURL=takeWhile.js.map