UNPKG

1.16 kBJavaScriptView Raw
1import { AsyncIterableX } from './asynciterablex';
2import { wrapWithAbort } from './operators/withabort';
3import { throwIfAborted } from '../aborterror';
4export class ConcatAsyncIterable extends AsyncIterableX {
5 constructor(source) {
6 super();
7 this._source = source;
8 }
9 async *[Symbol.asyncIterator](signal) {
10 throwIfAborted(signal);
11 for (const outer of this._source) {
12 for await (const item of wrapWithAbort(outer, signal)) {
13 yield item;
14 }
15 }
16 }
17}
18export function _concatAll(source) {
19 return new ConcatAsyncIterable(source);
20}
21/**
22 * Concatenates all async-iterable sequences in the given sequences, as long as the previous async-iterable
23 * sequence terminated successfully.
24 *
25 * @export
26 * @template T The type of the elements in the sequences.
27 * @param {...AsyncIterable<T>[]} args The async-iterable sources.
28 * @returns {AsyncIterableX<T>} An async-iterable sequence that contains the elements of each given sequence, in sequential order.
29 */
30export function concat(...args) {
31 return new ConcatAsyncIterable(args);
32}
33
34//# sourceMappingURL=concat.mjs.map