Debian Codegraph @

node/rxjs/dist/esm/internal/operators/skipLast.js

raw
1 import { identity } from '../util/identity';
2 import { operate } from '../util/lift';
3 import { createOperatorSubscriber } from './OperatorSubscriber';
4 export function skipLast(skipCount) {
5 return skipCount <= 0
6 ?
7 identity
8 : operate((source, subscriber) => {
9 let ring = new Array(skipCount);
10 let seen = 0;
11 source.subscribe(createOperatorSubscriber(subscriber, (value) => {
12 const valueIndex = seen++;
13 if (valueIndex < skipCount) {
14 ring[valueIndex] = value;
15 }
16 else {
17 const index = valueIndex % skipCount;
18 const oldValue = ring[index];
19 ring[index] = value;
20 subscriber.next(oldValue);
21 }
22 }));
23 return () => {
24 ring = null;
25 };
26 });
27 }
28 //# sourceMappingURL=skipLast.js.map