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