diff options
Diffstat (limited to 'test/node-fetch/utils/read-stream.js')
-rw-r--r-- | test/node-fetch/utils/read-stream.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/node-fetch/utils/read-stream.js b/test/node-fetch/utils/read-stream.js new file mode 100644 index 0000000..7d79153 --- /dev/null +++ b/test/node-fetch/utils/read-stream.js @@ -0,0 +1,9 @@ +module.exports = async function readStream (stream) { + const chunks = [] + + for await (const chunk of stream) { + chunks.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk)) + } + + return Buffer.concat(chunks) +} |