import { withMappedErrors } from "./error-mapping.js"; export interface NapiRecvSource { recv(): Promise; } export async function* mapAsyncIterable( source: NapiRecvSource, normalize: (raw: U) => T, ): AsyncGenerator { for (;;) { const raw = await withMappedErrors(() => source.recv()); if (raw === null) return; yield normalize(raw); } }