🧩 Skips items while a predicate is true, then yields the rest.

Syntax

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

dropWhileIterAsync<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(dropWhileIterAsync(gen(), x => x < 2)) //=> [2, 3]
Last updated on
Edit this page