🧩 Yields items from an async iterable as long as a predicate is true.
Syntax
TypeScript
import { takeWhileIterAsync } from '@opentf/std'; takeWhileIterAsync<T>(iter: AsyncIterable<T>, fn: (val: T) => boolean | Promise<boolean>): AsyncIterableIterator<T>
Parameters
iter: The source async iterable.fn: The predicate function.
Returns
A new async iterable iterator.
Examples
TypeScript
async function* gen() { yield 1; yield 2; yield 3; } await toArrayIterAsync(takeWhileIterAsync(gen(), x => x < 3)) //=> [1, 2]