I have a highland stream in which each element is a promise for a get request:
const stream = _[promise1, promise2, promise3, ...];
so of course when I run:
const stream.each(console.log)
I only see:
Promise { <pending> }
Promise { <pending> }
Promise { <pending> }
Yet I want to create a pipeline and work on the actual result of the promise. (I don't want to use then
or await
). I want to resolve these promises via a stream pipeline.
I imagine that there should be a way to make a highland stream to only map resolved promises into a new stream, so I expect to be able to flatten a stream of promises into a stream of their actual values.
Digging around, I suppose that either flatMap
or flatten
should do what I am looking for, yet I have no clue in how to proceed and all my trial and error has failed me.
I tried:
stream.flatMap((id: number) => {
return myAsyncGetRequest(id);
}).each(console.log)
How do I resolve promises within stream?