stream-to-promise
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -6,2 +6,5 @@ var toArray = require('stream-to-array'); | ||
return Promise.promisify(toArray)(stream) | ||
.map(function (part) { | ||
return (part instanceof Buffer) ? part : new Buffer(part); | ||
}) | ||
.then(Buffer.concat) | ||
@@ -8,0 +11,0 @@ .error(function (err) { |
{ | ||
"name": "stream-to-promise", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Convert readable streams to promises", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,2 +44,11 @@ 'use strict'; | ||
it('can handle streams of buffers and strings', function () { | ||
stream.emit('data', new Buffer('foo')); | ||
stream.emit('data', 'bar'); | ||
stream.emit('end'); | ||
return promise.then(function (buffer) { | ||
expect(buffer.toString()).to.equal('foobar'); | ||
}); | ||
}); | ||
it('resolves immediately for ended streams', function () { | ||
@@ -46,0 +55,0 @@ stream.readable = false; |
5156
64