UNPKG

601 BJavaScriptView Raw
1import { AsyncIterableX } from './asynciterablex';
2export class SkipLastAsyncIterable extends AsyncIterableX {
3 constructor(source, count) {
4 super();
5 this._source = source;
6 this._count = count;
7 }
8 async *[Symbol.asyncIterator]() {
9 let q = [];
10 for await (let item of this._source) {
11 q.push(item);
12 if (q.length > this._count) {
13 yield q.shift();
14 }
15 }
16 }
17}
18export function skipLast(source, count) {
19 return new SkipLastAsyncIterable(source, count);
20}
21
22//# sourceMappingURL=skiplast.mjs.map