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.

repeat.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /** PURE_IMPORTS_START tslib,_Subscriber,_observable_empty PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { Subscriber } from '../Subscriber';
  4. import { empty } from '../observable/empty';
  5. export function repeat(count) {
  6. if (count === void 0) {
  7. count = -1;
  8. }
  9. return function (source) {
  10. if (count === 0) {
  11. return empty();
  12. }
  13. else if (count < 0) {
  14. return source.lift(new RepeatOperator(-1, source));
  15. }
  16. else {
  17. return source.lift(new RepeatOperator(count - 1, source));
  18. }
  19. };
  20. }
  21. var RepeatOperator = /*@__PURE__*/ (function () {
  22. function RepeatOperator(count, source) {
  23. this.count = count;
  24. this.source = source;
  25. }
  26. RepeatOperator.prototype.call = function (subscriber, source) {
  27. return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
  28. };
  29. return RepeatOperator;
  30. }());
  31. var RepeatSubscriber = /*@__PURE__*/ (function (_super) {
  32. tslib_1.__extends(RepeatSubscriber, _super);
  33. function RepeatSubscriber(destination, count, source) {
  34. var _this = _super.call(this, destination) || this;
  35. _this.count = count;
  36. _this.source = source;
  37. return _this;
  38. }
  39. RepeatSubscriber.prototype.complete = function () {
  40. if (!this.isStopped) {
  41. var _a = this, source = _a.source, count = _a.count;
  42. if (count === 0) {
  43. return _super.prototype.complete.call(this);
  44. }
  45. else if (count > -1) {
  46. this.count = count - 1;
  47. }
  48. source.subscribe(this._unsubscribeAndRecycle());
  49. }
  50. };
  51. return RepeatSubscriber;
  52. }(Subscriber));
  53. //# sourceMappingURL=repeat.js.map