Skip to content

asyncConcat

The asyncConcat() function concatenates synchronous or asynchronous iterables into one async generator, in input order.

Interactive example

Syntax

typescript
function asyncConcat<
	const GenericElement extends unknown,
>(
	elements: AsyncIterable<GenericElement> | Iterable<GenericElement>,
): (
	iterator: AsyncIterable<GenericElement> | Iterable<GenericElement>
) => AsyncGenerator<GenericElement, void, unknown>;

function asyncConcat<
	const GenericElement extends unknown,
>(
	iterator: AsyncIterable<GenericElement> | Iterable<GenericElement>,
	elements: AsyncIterable<GenericElement> | Iterable<GenericElement>,
	...elementsRest: (AsyncIterable<GenericElement> | Iterable<GenericElement>)[]
): AsyncGenerator<GenericElement, void, unknown>;

Parameters

  • iterator: Source iterable or async iterable (classic style only).
  • elements: Iterable or async iterable to append at the end.
  • elementsRest: Additional iterables or async iterables appended in order.

Return value

A lazy AsyncGenerator emitting values from all inputs in order.

See also

  • concat - Sync iterable version
  • asyncFlat - Flattens async/sync nested iterables
  • asyncMap - Transforms values asynchronously

Released under the MIT license.