frontend/.pnpm-store/v3/files/53/653625b0709e96837099995f8aa6626c0751a37cfd2f87631fe06e2ab7561cd656b7dddf42a7c2a5fe355f63e6d50d90f786eea0a13b962bbcb1f4449e366e

28 lines
979 B
Plaintext

import { identity } from '../util/identity';
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function skipLast(skipCount) {
return skipCount <= 0
?
identity
: operate(function (source, subscriber) {
var ring = new Array(skipCount);
var seen = 0;
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
var valueIndex = seen++;
if (valueIndex < skipCount) {
ring[valueIndex] = value;
}
else {
var index = valueIndex % skipCount;
var oldValue = ring[index];
ring[index] = value;
subscriber.next(oldValue);
}
}));
return function () {
ring = null;
};
});
}
//# sourceMappingURL=skipLast.js.map