stream-to-array
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -38,3 +38,3 @@ | ||
function onClose() { | ||
resolve() | ||
resolve(arr) | ||
cleanup() | ||
@@ -41,0 +41,0 @@ } |
{ | ||
"name": "stream-to-array", | ||
"description": "Concatenate a readable stream's data into a single array", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"author": { | ||
@@ -18,4 +18,4 @@ "name": "Jonathan Ong", | ||
"devDependencies": { | ||
"mocha": "1", | ||
"istanbul": "0" | ||
"istanbul": "0", | ||
"mocha": "^2.3.3" | ||
}, | ||
@@ -22,0 +22,0 @@ "scripts": { |
@@ -9,3 +9,2 @@ # Stream to Array | ||
[![Downloads][downloads-image]][downloads-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
@@ -46,10 +45,9 @@ Concatenate a readable stream's data into a single array. | ||
If `callback` is not defined, then it is assumed that it is being yielded within a generator. | ||
If `callback` is not defined, then it returns a promise. | ||
```js | ||
function* () { | ||
var stream = new Stream.Readable() | ||
stream.toArray = toArray | ||
var arr = yield stream.toArray() | ||
} | ||
toArray(stream) | ||
.then(function (parts) { | ||
}) | ||
``` | ||
@@ -60,5 +58,11 @@ | ||
```js | ||
var stream = new Stream.Readable() | ||
var arr = yield toArray(stream) | ||
var buffer = Buffer.concat(arr) | ||
toArray(stream) | ||
.then(function (parts) { | ||
var buffers = [] | ||
for (var i = 0, l = parts.length; i < l ; ++i) { | ||
var part = parts[i] | ||
buffers.push((part instanceof Buffer) ? part : new Buffer(part)) | ||
} | ||
return Buffer.concat(buffers) | ||
}) | ||
``` | ||
@@ -80,3 +84,1 @@ | ||
[downloads-url]: https://npmjs.org/package/stream-to-array | ||
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square | ||
[gittip-url]: https://www.gittip.com/jonathanong/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5676
4
81