UNPKG

ix

Version:

The Interactive Extensions for JavaScript

51 lines (49 loc) 1.95 kB
import { __asyncGenerator, __asyncValues, __await } from "tslib"; import { AsyncIterableX } from './asynciterablex.mjs'; import { wrapWithAbort } from './operators/withabort.mjs'; import { throwIfAborted } from '../aborterror.mjs'; /** @ignore */ export class ConcatAsyncIterable extends AsyncIterableX { constructor(source) { super(); this._source = source; } [Symbol.asyncIterator](signal) { return __asyncGenerator(this, arguments, function* _a() { var _b, e_1, _c, _d; throwIfAborted(signal); for (const outer of this._source) { try { for (var _e = true, _f = (e_1 = void 0, __asyncValues(wrapWithAbort(outer, signal))), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) { _d = _g.value; _e = false; const item = _d; yield yield __await(item); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (!_e && !_b && (_c = _f.return)) yield __await(_c.call(_f)); } finally { if (e_1) throw e_1.error; } } } }); } } export function _concatAll(source) { return new ConcatAsyncIterable(source); } /** * Concatenates all async-iterable sequences in the given sequences, as long as the previous async-iterable * sequence terminated successfully. * * @template T The type of the elements in the sequences. * @param {...AsyncIterable<T>[]} args The async-iterable sources. * @returns {AsyncIterableX<T>} An async-iterable sequence that contains the elements of each given sequence, in sequential order. */ export function concat(...args) { return new ConcatAsyncIterable(args); } //# sourceMappingURL=concat.mjs.map