stream-to-string
Advanced tools
Comparing version 1.0.1 to 1.1.0
var Promise = require('promise-polyfill') | ||
module.exports = function (stream, cb) { | ||
module.exports = function (stream, enc, cb) { | ||
if (typeof enc === 'function') { | ||
cb = enc | ||
enc = null | ||
} | ||
cb = cb || function () {} | ||
var str = '' | ||
@@ -9,3 +14,3 @@ | ||
stream.on('data', function (data) { | ||
str += data.toString() | ||
str += (typeof enc === 'string') ? data.toString(enc) : data.toString() | ||
}) | ||
@@ -12,0 +17,0 @@ stream.on('end', function () { |
{ | ||
"name": "stream-to-string", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Pipe a stream into a string, collect value with callback or promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,2 @@ # stream-to-string | ||
[![Coverage Status](https://coveralls.io/repos/jasonpincin/stream-to-string/badge.png?branch=master)](https://coveralls.io/r/jasonpincin/stream-to-string?branch=master) | ||
[![Davis Dependency Status](https://david-dm.org/jasonpincin/stream-to-string.png)](https://david-dm.org/jasonpincin/stream-to-string) | ||
@@ -38,5 +37,5 @@ Pipe a stream into a string, collect value with callback or promise | ||
### toString(stream [, cb]) | ||
### toString(stream[, enc][, cb]) | ||
Collects stream data into a string. Executes optional callback with `err, string`. Returns a promise. | ||
Collects stream data into a string. Accepts an optional encoding argument used when converting the stream. Executes optional callback with `err, string`. Returns a promise. | ||
@@ -43,0 +42,0 @@ ## testing |
Sorry, the diff of this file is not supported yet
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
9667
14
90
50