diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-02-10 09:05:01 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-02-10 09:44:08 +0300 |
commit | acebfcf38ea2d7a17286522d9ed71d751f88bee5 (patch) | |
tree | b589e27f6903f150f706625f1fd12634765c59df /lib | |
parent | f251050f6cb96f622c390b7ebc49ca007ed8c0e1 (diff) |
client.seed: fix stream input type
convert streams to buffer, since we need to consume the stream twice.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/concat-stream.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/concat-stream.js b/lib/concat-stream.js new file mode 100644 index 0000000..c2d8860 --- /dev/null +++ b/lib/concat-stream.js @@ -0,0 +1,14 @@ +module.exports = function (stream, cb) { + var chunks = [] + stream.on('data', function (chunk) { + chunks.push(chunk) + }) + stream.once('end', function () { + if (cb) cb(null, Buffer.concat(chunks)) + cb = null + }) + stream.once('error', function (err) { + if (cb) cb(err) + cb = null + }) +} |