The type of values yielded by the source
The type of the final return value
The type of errors that may be thrown
A promise that resolves when the piping operation completes
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!"
Pipes values from an async source to an async sink, forwarding all yielded values, the final return value, and any errors that occur.
Consumes the source and calls the appropriate sink methods:
next()for each yielded value,complete()when the source finishes successfully, anderror()if the source throws.