Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

skipWhile.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { Subscriber } from '../Subscriber';
  4. export function skipWhile(predicate) {
  5. return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
  6. }
  7. var SkipWhileOperator = /*@__PURE__*/ (function () {
  8. function SkipWhileOperator(predicate) {
  9. this.predicate = predicate;
  10. }
  11. SkipWhileOperator.prototype.call = function (subscriber, source) {
  12. return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
  13. };
  14. return SkipWhileOperator;
  15. }());
  16. var SkipWhileSubscriber = /*@__PURE__*/ (function (_super) {
  17. tslib_1.__extends(SkipWhileSubscriber, _super);
  18. function SkipWhileSubscriber(destination, predicate) {
  19. var _this = _super.call(this, destination) || this;
  20. _this.predicate = predicate;
  21. _this.skipping = true;
  22. _this.index = 0;
  23. return _this;
  24. }
  25. SkipWhileSubscriber.prototype._next = function (value) {
  26. var destination = this.destination;
  27. if (this.skipping) {
  28. this.tryCallPredicate(value);
  29. }
  30. if (!this.skipping) {
  31. destination.next(value);
  32. }
  33. };
  34. SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
  35. try {
  36. var result = this.predicate(value, this.index++);
  37. this.skipping = Boolean(result);
  38. }
  39. catch (err) {
  40. this.destination.error(err);
  41. }
  42. };
  43. return SkipWhileSubscriber;
  44. }(Subscriber));
  45. //# sourceMappingURL=skipWhile.js.map