🧩 Transforms each item in an async iterator using a mapper function.

Syntax

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

mapIterAsync<T, U>(iter: AsyncIterable<T>, fn: (val: T) => U | Promise<U>): AsyncIterableIterator<U>

Parameters

  • iter: The async iterable to transform.

  • fn: The mapper function.

Returns

A new async iterable iterator.

Examples

TypeScript
async function* gen() { yield 1; yield 2; }
await toArrayIterAsync(mapIterAsync(gen(), x => x * 2)) //=> [2, 4]
Last updated on
Edit this page