1 | import { AsyncIterableX } from './asynciterablex';
|
2 | export class TakeAsyncIterable extends AsyncIterableX {
|
3 | constructor(source, count) {
|
4 | super();
|
5 | this._source = source;
|
6 | this._count = count;
|
7 | }
|
8 | async *[Symbol.asyncIterator]() {
|
9 | let i = this._count;
|
10 | if (i > 0) {
|
11 | for await (let item of this._source) {
|
12 | yield item;
|
13 | if (--i === 0) {
|
14 | break;
|
15 | }
|
16 | }
|
17 | }
|
18 | }
|
19 | }
|
20 | export function take(source, count) {
|
21 | return new TakeAsyncIterable(source, count);
|
22 | }
|
23 |
|
24 | //# sourceMappingURL=take.mjs.map
|