source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/skipLast.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber,_util_ArgumentOutOfRangeError PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
5export function skipLast(count) {
6 return function (source) { return source.lift(new SkipLastOperator(count)); };
7}
8var SkipLastOperator = /*@__PURE__*/ (function () {
9 function SkipLastOperator(_skipCount) {
10 this._skipCount = _skipCount;
11 if (this._skipCount < 0) {
12 throw new ArgumentOutOfRangeError;
13 }
14 }
15 SkipLastOperator.prototype.call = function (subscriber, source) {
16 if (this._skipCount === 0) {
17 return source.subscribe(new Subscriber(subscriber));
18 }
19 else {
20 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
21 }
22 };
23 return SkipLastOperator;
24}());
25var SkipLastSubscriber = /*@__PURE__*/ (function (_super) {
26 tslib_1.__extends(SkipLastSubscriber, _super);
27 function SkipLastSubscriber(destination, _skipCount) {
28 var _this = _super.call(this, destination) || this;
29 _this._skipCount = _skipCount;
30 _this._count = 0;
31 _this._ring = new Array(_skipCount);
32 return _this;
33 }
34 SkipLastSubscriber.prototype._next = function (value) {
35 var skipCount = this._skipCount;
36 var count = this._count++;
37 if (count < skipCount) {
38 this._ring[count] = value;
39 }
40 else {
41 var currentIndex = count % skipCount;
42 var ring = this._ring;
43 var oldValue = ring[currentIndex];
44 ring[currentIndex] = value;
45 this.destination.next(oldValue);
46 }
47 };
48 return SkipLastSubscriber;
49}(Subscriber));
50//# sourceMappingURL=skipLast.js.map
Note: See TracBrowser for help on using the repository browser.