🧩 Checks if all items in an async iterator match a predicate.

Syntax

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

everyIterAsync<T>(iter: AsyncIterable<T>, fn: (val: T) => boolean | Promise<boolean>): Promise<boolean>

Parameters

  • iter: The async iterable to check.

  • fn: The predicate function.

Returns

A promise that resolves to true if all items match, else false.

Examples

TypeScript
async function* gen() { yield 1; yield 2; }
await everyIterAsync(gen(), x => x > 0) //=> true
Last updated on
Edit this page