1 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscriber } from '../Subscriber';
4 export function scan(accumulator, seed) {
6 if (arguments.length >= 2) {
9 return function scanOperatorFunction(source) {
10 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
13 var ScanOperator = /*@__PURE__*/ (function () {
14 function ScanOperator(accumulator, seed, hasSeed) {
15 if (hasSeed === void 0) {
18 this.accumulator = accumulator;
20 this.hasSeed = hasSeed;
22 ScanOperator.prototype.call = function (subscriber, source) {
23 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
27 var ScanSubscriber = /*@__PURE__*/ (function (_super) {
28 tslib_1.__extends(ScanSubscriber, _super);
29 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
30 var _this = _super.call(this, destination) || this;
31 _this.accumulator = accumulator;
33 _this.hasSeed = hasSeed;
37 Object.defineProperty(ScanSubscriber.prototype, "seed", {
41 set: function (value) {
48 ScanSubscriber.prototype._next = function (value) {
51 this.destination.next(value);
54 return this._tryNext(value);
57 ScanSubscriber.prototype._tryNext = function (value) {
58 var index = this.index++;
61 result = this.accumulator(this.seed, value, index);
64 this.destination.error(err);
67 this.destination.next(result);
69 return ScanSubscriber;
71 //# sourceMappingURL=scan.js.map