2 var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Subscriber_1 = require("../Subscriber");
17 function scan(accumulator, seed) {
19 if (arguments.length >= 2) {
22 return function scanOperatorFunction(source) {
23 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
27 var ScanOperator = (function () {
28 function ScanOperator(accumulator, seed, hasSeed) {
29 if (hasSeed === void 0) { hasSeed = false; }
30 this.accumulator = accumulator;
32 this.hasSeed = hasSeed;
34 ScanOperator.prototype.call = function (subscriber, source) {
35 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
39 var ScanSubscriber = (function (_super) {
40 __extends(ScanSubscriber, _super);
41 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
42 var _this = _super.call(this, destination) || this;
43 _this.accumulator = accumulator;
45 _this.hasSeed = hasSeed;
49 Object.defineProperty(ScanSubscriber.prototype, "seed", {
53 set: function (value) {
60 ScanSubscriber.prototype._next = function (value) {
63 this.destination.next(value);
66 return this._tryNext(value);
69 ScanSubscriber.prototype._tryNext = function (value) {
70 var index = this.index++;
73 result = this.accumulator(this.seed, value, index);
76 this.destination.error(err);
79 this.destination.next(result);
81 return ScanSubscriber;
82 }(Subscriber_1.Subscriber));
83 //# sourceMappingURL=scan.js.map