1 | import { AsyncIterableX } from './asynciterablex';
|
2 | export class SkipAsyncIterable extends AsyncIterableX {
|
3 | constructor(source, count) {
|
4 | super();
|
5 | this._source = source;
|
6 | this._count = count;
|
7 | }
|
8 | async *[Symbol.asyncIterator]() {
|
9 | let it = this._source[Symbol.asyncIterator](), count = this._count, next;
|
10 | while (count > 0 && !(next = await it.next()).done) {
|
11 | count--;
|
12 | }
|
13 | if (count <= 0) {
|
14 | while (!(next = await it.next()).done) {
|
15 | yield next.value;
|
16 | }
|
17 | }
|
18 | }
|
19 | }
|
20 | export function skip(source, count) {
|
21 | return new SkipAsyncIterable(source, count);
|
22 | }
|
23 |
|
24 |
|