🧩 Executes a function for each item in an async iterator.
Syntax
TypeScript
import { eachIterAsync } from '@opentf/std'; eachIterAsync<T>(iter: AsyncIterable<T>, fn: (val: T) => void | Promise<void>): Promise<void>
Parameters
iter: The async iterable to iterate over.fn: The function to execute.
Returns
A promise that resolves when iteration is complete.
Examples
TypeScript
async function* gen() { yield 1; yield 2; } await eachIterAsync(gen(), x => console.log(x)) //=> Logs 1, 2