stream-to-string
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,4 +0,17 @@ | ||
declare module 'stream-to-string' { | ||
const streamToString: (stream: NodeJS.ReadableStream) => Promise<string>; | ||
export = streamToString; | ||
/// <reference types="node" /> | ||
export = streamToString; | ||
declare function streamToString( | ||
stream: NodeJS.ReadableStream, | ||
cb?: streamToString.Callback | ||
): Promise<string>; | ||
declare function streamToString( | ||
stream: NodeJS.ReadableStream, | ||
enc: string, | ||
cb?: streamToString.Callback | ||
): Promise<string>; | ||
declare namespace streamToString { | ||
type Callback = (error: Error | undefined, str: string) => void; | ||
} |
13
index.js
@@ -8,7 +8,6 @@ var Promise = require('promise-polyfill') | ||
} | ||
cb = cb || function () {} | ||
var str = '' | ||
return new Promise (function (resolve, reject) { | ||
var p = new Promise (function (resolve, reject) { | ||
stream.on('data', function (data) { | ||
@@ -19,9 +18,9 @@ str += (typeof enc === 'string') ? data.toString(enc) : data.toString() | ||
resolve(str) | ||
cb(null, str) | ||
}) | ||
stream.on('error', function (err) { | ||
reject(err) | ||
cb(err) | ||
}) | ||
stream.on('error', reject) | ||
}) | ||
if (cb) { | ||
p.then(function (str) { cb(null, str) }, cb) | ||
} | ||
return p | ||
} |
{ | ||
"name": "stream-to-string", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Pipe a stream into a string, collect value with callback or promise", | ||
@@ -33,2 +33,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/node": "*", | ||
"istanbul": "~0.2.8", | ||
@@ -39,7 +40,11 @@ "jshint": "^2.5.6", | ||
"tape": "~4.0.1", | ||
"through2": "^0.6.3" | ||
"through2": "^0.6.3", | ||
"tsd": "^0.25.0" | ||
}, | ||
"dependencies": { | ||
"promise-polyfill": "^1.1.6" | ||
}, | ||
"tsd": { | ||
"directory": "test" | ||
} | ||
} |
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
10716
16
122
8