Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / windowCount.js
1 /** PURE_IMPORTS_START tslib,_Subscriber,_Subject PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscriber } from '../Subscriber';
4 import { Subject } from '../Subject';
5 export function windowCount(windowSize, startWindowEvery) {
6     if (startWindowEvery === void 0) {
7         startWindowEvery = 0;
8     }
9     return function windowCountOperatorFunction(source) {
10         return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
11     };
12 }
13 var WindowCountOperator = /*@__PURE__*/ (function () {
14     function WindowCountOperator(windowSize, startWindowEvery) {
15         this.windowSize = windowSize;
16         this.startWindowEvery = startWindowEvery;
17     }
18     WindowCountOperator.prototype.call = function (subscriber, source) {
19         return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
20     };
21     return WindowCountOperator;
22 }());
23 var WindowCountSubscriber = /*@__PURE__*/ (function (_super) {
24     tslib_1.__extends(WindowCountSubscriber, _super);
25     function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
26         var _this = _super.call(this, destination) || this;
27         _this.destination = destination;
28         _this.windowSize = windowSize;
29         _this.startWindowEvery = startWindowEvery;
30         _this.windows = [new Subject()];
31         _this.count = 0;
32         destination.next(_this.windows[0]);
33         return _this;
34     }
35     WindowCountSubscriber.prototype._next = function (value) {
36         var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
37         var destination = this.destination;
38         var windowSize = this.windowSize;
39         var windows = this.windows;
40         var len = windows.length;
41         for (var i = 0; i < len && !this.closed; i++) {
42             windows[i].next(value);
43         }
44         var c = this.count - windowSize + 1;
45         if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
46             windows.shift().complete();
47         }
48         if (++this.count % startWindowEvery === 0 && !this.closed) {
49             var window_1 = new Subject();
50             windows.push(window_1);
51             destination.next(window_1);
52         }
53     };
54     WindowCountSubscriber.prototype._error = function (err) {
55         var windows = this.windows;
56         if (windows) {
57             while (windows.length > 0 && !this.closed) {
58                 windows.shift().error(err);
59             }
60         }
61         this.destination.error(err);
62     };
63     WindowCountSubscriber.prototype._complete = function () {
64         var windows = this.windows;
65         if (windows) {
66             while (windows.length > 0 && !this.closed) {
67                 windows.shift().complete();
68             }
69         }
70         this.destination.complete();
71     };
72     WindowCountSubscriber.prototype._unsubscribe = function () {
73         this.count = 0;
74         this.windows = null;
75     };
76     return WindowCountSubscriber;
77 }(Subscriber));
78 //# sourceMappingURL=windowCount.js.map