| "use strict"; | |
| var __extends = (this && this.__extends) || (function () { | |
| var extendStatics = function (d, b) { | |
| extendStatics = Object.setPrototypeOf || | |
| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
| function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | |
| return extendStatics(d, b); | |
| } | |
| return function (d, b) { | |
| extendStatics(d, b); | |
| function __() { this.constructor = d; } | |
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
| }; | |
| })(); | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| var Subscriber_1 = require("../Subscriber"); | |
| var empty_1 = require("../observable/empty"); | |
| function repeat(count) { | |
| if (count === void 0) { count = -1; } | |
| return function (source) { | |
| if (count === 0) { | |
| return empty_1.empty(); | |
| } | |
| else if (count < 0) { | |
| return source.lift(new RepeatOperator(-1, source)); | |
| } | |
| else { | |
| return source.lift(new RepeatOperator(count - 1, source)); | |
| } | |
| }; | |
| } | |
| exports.repeat = repeat; | |
| var RepeatOperator = (function () { | |
| function RepeatOperator(count, source) { | |
| this.count = count; | |
| this.source = source; | |
| } | |
| RepeatOperator.prototype.call = function (subscriber, source) { | |
| return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source)); | |
| }; | |
| return RepeatOperator; | |
| }()); | |
| var RepeatSubscriber = (function (_super) { | |
| __extends(RepeatSubscriber, _super); | |
| function RepeatSubscriber(destination, count, source) { | |
| var _this = _super.call(this, destination) || this; | |
| _this.count = count; | |
| _this.source = source; | |
| return _this; | |
| } | |
| RepeatSubscriber.prototype.complete = function () { | |
| if (!this.isStopped) { | |
| var _a = this, source = _a.source, count = _a.count; | |
| if (count === 0) { | |
| return _super.prototype.complete.call(this); | |
| } | |
| else if (count > -1) { | |
| this.count = count - 1; | |
| } | |
| source.subscribe(this._unsubscribeAndRecycle()); | |
| } | |
| }; | |
| return RepeatSubscriber; | |
| }(Subscriber_1.Subscriber)); | |
| //# sourceMappingURL=repeat.js.map |