🔗 Creates an AsyncIterableIterator from an iterable, async iterable, or iterator-like object.

Syntax

TypeScript
import { fromIterAsync } from '@opentf/std';

fromIterAsync<T>(iter: AsyncIterable<T> | Iterable<T> | { next: () => Promise<IteratorResult<T>> | IteratorResult<T> }): AsyncIterableIterator<T>

Parameters

  • iter: The source object.

Returns

A new async iterable iterator.

If the source iterator exposes return() or throw(), the wrapped async iterator forwards those methods so early loop exit and errors can close the underlying iterator correctly.

Examples

TypeScript
await toArrayIterAsync(fromIterAsync([1, 2, 3])) //=> [1, 2, 3]
Last updated on
Edit this page