@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
25 lines (23 loc) • 664 B
JavaScript
import { AsyncIterableX } from '../asynciterablex';
export class SkipLastAsyncIterable extends AsyncIterableX {
constructor(source, count) {
super();
this._source = source;
this._count = count;
}
async *[Symbol.asyncIterator]() {
const q = [];
for await (const item of this._source) {
q.push(item);
if (q.length > this._count) {
yield q.shift();
}
}
}
}
export function skipLast(count) {
return function skipLastOperatorFunction(source) {
return new SkipLastAsyncIterable(source, count);
};
}
//# sourceMappingURL=skiplast.mjs.map