source: trip-planner-front/node_modules/rxjs/internal/operators/scan.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.7 KB
Line 
1"use strict";
2var __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);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var Subscriber_1 = require("../Subscriber");
17function scan(accumulator, seed) {
18 var hasSeed = false;
19 if (arguments.length >= 2) {
20 hasSeed = true;
21 }
22 return function scanOperatorFunction(source) {
23 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
24 };
25}
26exports.scan = scan;
27var ScanOperator = (function () {
28 function ScanOperator(accumulator, seed, hasSeed) {
29 if (hasSeed === void 0) { hasSeed = false; }
30 this.accumulator = accumulator;
31 this.seed = seed;
32 this.hasSeed = hasSeed;
33 }
34 ScanOperator.prototype.call = function (subscriber, source) {
35 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
36 };
37 return ScanOperator;
38}());
39var 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;
44 _this._seed = _seed;
45 _this.hasSeed = hasSeed;
46 _this.index = 0;
47 return _this;
48 }
49 Object.defineProperty(ScanSubscriber.prototype, "seed", {
50 get: function () {
51 return this._seed;
52 },
53 set: function (value) {
54 this.hasSeed = true;
55 this._seed = value;
56 },
57 enumerable: true,
58 configurable: true
59 });
60 ScanSubscriber.prototype._next = function (value) {
61 if (!this.hasSeed) {
62 this.seed = value;
63 this.destination.next(value);
64 }
65 else {
66 return this._tryNext(value);
67 }
68 };
69 ScanSubscriber.prototype._tryNext = function (value) {
70 var index = this.index++;
71 var result;
72 try {
73 result = this.accumulator(this.seed, value, index);
74 }
75 catch (err) {
76 this.destination.error(err);
77 }
78 this.seed = result;
79 this.destination.next(result);
80 };
81 return ScanSubscriber;
82}(Subscriber_1.Subscriber));
83//# sourceMappingURL=scan.js.map
Note: See TracBrowser for help on using the repository browser.