Yielded value type.
Final return value type.
Thrown error type.
Resolves after source completion or an error has been delivered to the sink.
Sink methods run synchronously and are not awaited. A source error is handled
by sink.error() and does not itself reject the returned promise; a throwing
sink method does reject it and stops piping.
const sink: AsyncSink<number, void> = {
next: (n) => console.log(`Value: ${n}`),
complete: () => console.log('Done!'),
error: (err) => console.error('Error:', err),
};
async function* gen() {
yield 1;
yield 2;
yield 3;
}
await pipeToAsyncSink(gen(), sink);
// Logs: "Value: 1", "Value: 2", "Value: 3", "Done!"
Consumes an async source, forwarding yields to
sink.next(), its final return value tosink.complete(), and failures advancing the source tosink.error().