a zip code crypto-currency system good for red ONLY

takeWhile.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /** PURE_IMPORTS_START .._operators_takeWhile PURE_IMPORTS_END */
  2. import { takeWhile as higherOrder } from '../operators/takeWhile';
  3. /**
  4. * Emits values emitted by the source Observable so long as each value satisfies
  5. * the given `predicate`, and then completes as soon as this `predicate` is not
  6. * satisfied.
  7. *
  8. * <span class="informal">Takes values from the source only while they pass the
  9. * condition given. When the first value does not satisfy, it completes.</span>
  10. *
  11. * <img src="./img/takeWhile.png" width="100%">
  12. *
  13. * `takeWhile` subscribes and begins mirroring the source Observable. Each value
  14. * emitted on the source is given to the `predicate` function which returns a
  15. * boolean, representing a condition to be satisfied by the source values. The
  16. * output Observable emits the source values until such time as the `predicate`
  17. * returns false, at which point `takeWhile` stops mirroring the source
  18. * Observable and completes the output Observable.
  19. *
  20. * @example <caption>Emit click events only while the clientX property is greater than 200</caption>
  21. * var clicks = Rx.Observable.fromEvent(document, 'click');
  22. * var result = clicks.takeWhile(ev => ev.clientX > 200);
  23. * result.subscribe(x => console.log(x));
  24. *
  25. * @see {@link take}
  26. * @see {@link takeLast}
  27. * @see {@link takeUntil}
  28. * @see {@link skip}
  29. *
  30. * @param {function(value: T, index: number): boolean} predicate A function that
  31. * evaluates a value emitted by the source Observable and returns a boolean.
  32. * Also takes the (zero-based) index as the second argument.
  33. * @return {Observable<T>} An Observable that emits the values from the source
  34. * Observable so long as each value satisfies the condition defined by the
  35. * `predicate`, then completes.
  36. * @method takeWhile
  37. * @owner Observable
  38. */
  39. export function takeWhile(predicate) {
  40. return higherOrder(predicate)(this);
  41. }
  42. //# sourceMappingURL=takeWhile.js.map