module: prefer async/await in https imports
cc @bmeck @nodejs/modules
This PR refactors the fetch_module fetchWithRedirects
function to use the new modern facilities for streams:
-
compose
instead ofpipe
for simplified and "more easily correct" error handling on the body stream cc @ronag . -
async/await
overnew Promise
. -
toArray()
on the response body instead of manually.
Note this can probably be further simplified by always caching the promise (and never the value) and by moving the "memoize" functionality to a helper).