source: trip-planner-front/node_modules/rxjs/_esm2015/internal/operators/skipLast.js@ 6a3a178

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

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import { Subscriber } from '../Subscriber';
2import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
3export function skipLast(count) {
4 return (source) => source.lift(new SkipLastOperator(count));
5}
6class SkipLastOperator {
7 constructor(_skipCount) {
8 this._skipCount = _skipCount;
9 if (this._skipCount < 0) {
10 throw new ArgumentOutOfRangeError;
11 }
12 }
13 call(subscriber, source) {
14 if (this._skipCount === 0) {
15 return source.subscribe(new Subscriber(subscriber));
16 }
17 else {
18 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
19 }
20 }
21}
22class SkipLastSubscriber extends Subscriber {
23 constructor(destination, _skipCount) {
24 super(destination);
25 this._skipCount = _skipCount;
26 this._count = 0;
27 this._ring = new Array(_skipCount);
28 }
29 _next(value) {
30 const skipCount = this._skipCount;
31 const count = this._count++;
32 if (count < skipCount) {
33 this._ring[count] = value;
34 }
35 else {
36 const currentIndex = count % skipCount;
37 const ring = this._ring;
38 const oldValue = ring[currentIndex];
39 ring[currentIndex] = value;
40 this.destination.next(oldValue);
41 }
42 }
43}
44//# sourceMappingURL=skipLast.js.map
Note: See TracBrowser for help on using the repository browser.