🧩 Returns the first item from an async iterable.
Syntax
TypeScript
import { firstIterAsync } from '@opentf/std'; firstIterAsync<T>(iter: AsyncIterable<T>): Promise<T | undefined>
Parameters
iter: The async iterable to search.
Returns
A promise that resolves to the first item, or undefined.
Examples
TypeScript
async function* gen() { yield 1; yield 2; } await firstIterAsync(gen()) //=> 1