I have an async generator function defined, and want to create a second async generator function that is a partial application of the first function. For example, this works:
async function* fn1(a, b) {/* do something */}
async function* fn2() {
const a1 = fn1(0, 0);
for await (const value of a1) {
yield value;
}
}
My question is: is there a more concise way to define fn2?
fn1returns the async iterable thatfn2is iterating over, so rather than iterating manually infn2, you can just yield the iterable created fromfn1and letfn2's consumer handle it: