This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function mergeResponses(responsePromises) { | |
const headers = new Headers(); | |
headers.append("Content-Type", "text/html"); | |
const { readable, writable } = new TransformStream(); | |
const response = new Response(readable, { | |
headers: { "Content-Type": "text/html" }, | |
}); | |
const done = (async function() { | |
for await (const response of responsePromises) { | |
await response.body.pipeTo(writable, { preventClose: true }); | |
} | |
writable.getWriter().close(); | |
})(); | |
return { done, response }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment