a zip code crypto-currency system good for red ONLY

skipWhile.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /** PURE_IMPORTS_START .._Subscriber PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Subscriber } from '../Subscriber';
  10. /**
  11. * Returns an Observable that skips all items emitted by the source Observable as long as a specified condition holds
  12. * true, but emits all further source items as soon as the condition becomes false.
  13. *
  14. * <img src="./img/skipWhile.png" width="100%">
  15. *
  16. * @param {Function} predicate - A function to test each item emitted from the source Observable.
  17. * @return {Observable<T>} An Observable that begins emitting items emitted by the source Observable when the
  18. * specified predicate becomes false.
  19. * @method skipWhile
  20. * @owner Observable
  21. */
  22. export function skipWhile(predicate) {
  23. return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
  24. }
  25. var SkipWhileOperator = /*@__PURE__*/ (/*@__PURE__*/ function () {
  26. function SkipWhileOperator(predicate) {
  27. this.predicate = predicate;
  28. }
  29. SkipWhileOperator.prototype.call = function (subscriber, source) {
  30. return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
  31. };
  32. return SkipWhileOperator;
  33. }());
  34. /**
  35. * We need this JSDoc comment for affecting ESDoc.
  36. * @ignore
  37. * @extends {Ignored}
  38. */
  39. var SkipWhileSubscriber = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  40. __extends(SkipWhileSubscriber, _super);
  41. function SkipWhileSubscriber(destination, predicate) {
  42. _super.call(this, destination);
  43. this.predicate = predicate;
  44. this.skipping = true;
  45. this.index = 0;
  46. }
  47. SkipWhileSubscriber.prototype._next = function (value) {
  48. var destination = this.destination;
  49. if (this.skipping) {
  50. this.tryCallPredicate(value);
  51. }
  52. if (!this.skipping) {
  53. destination.next(value);
  54. }
  55. };
  56. SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
  57. try {
  58. var result = this.predicate(value, this.index++);
  59. this.skipping = Boolean(result);
  60. }
  61. catch (err) {
  62. this.destination.error(err);
  63. }
  64. };
  65. return SkipWhileSubscriber;
  66. }(Subscriber));
  67. //# sourceMappingURL=skipWhile.js.map