proposal-pipeline-operator-for-function-composition
proposal-pipeline-operator-for-function-composition copied to clipboard
How does this work with multiple generators?
trafficstars
The introduction of a generator into the pipeline implicitly invokes some looping, producing a generator as output. But what happens when you pipeline together two generators?
Like, say you have:
function* range(n) { for(const i = 0; i < n; i++) yield n; }
function* fbb(n) { yield "foo"+n; yield "bar"+n; yield "baz"+n; }
const what = range +> fbb +> (x=>console.log(x));
what(5); // what happens?
Does this implicitly loop twice, calling the final function 15 times in total?
Yes exactly.