1 /** PURE_IMPORTS_START tslib,_Subscriber,_util_ArgumentOutOfRangeError PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscriber } from '../Subscriber';
4 import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
5 export function skipLast(count) {
6 return function (source) { return source.lift(new SkipLastOperator(count)); };
8 var SkipLastOperator = /*@__PURE__*/ (function () {
9 function SkipLastOperator(_skipCount) {
10 this._skipCount = _skipCount;
11 if (this._skipCount < 0) {
12 throw new ArgumentOutOfRangeError;
15 SkipLastOperator.prototype.call = function (subscriber, source) {
16 if (this._skipCount === 0) {
17 return source.subscribe(new Subscriber(subscriber));
20 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
23 return SkipLastOperator;
25 var 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;
31 _this._ring = new Array(_skipCount);
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;
41 var currentIndex = count % skipCount;
42 var ring = this._ring;
43 var oldValue = ring[currentIndex];
44 ring[currentIndex] = value;
45 this.destination.next(oldValue);
48 return SkipLastSubscriber;
50 //# sourceMappingURL=skipLast.js.map