Comparing version 0.0.3 to 0.1.0
31
index.js
@@ -1,7 +0,10 @@ | ||
module.exports = function (stream, options, callback) { | ||
module.exports = function (stream, options, done) { | ||
if (typeof options === 'function') { | ||
callback = options | ||
done = options | ||
options = {} | ||
} | ||
if (!options) | ||
options = {} | ||
var limit = typeof options.limit === 'number' | ||
@@ -20,6 +23,7 @@ ? options.limit | ||
err.limit = limit | ||
callback(err) | ||
stream.resume() // dump stream | ||
cleanup() | ||
return | ||
process.nextTick(function () { | ||
done(err) | ||
}) | ||
return defer | ||
} | ||
@@ -32,6 +36,11 @@ | ||
stream.once('end', onEnd) | ||
stream.once('error', callback) | ||
stream.once('error', cleanup) | ||
stream.once('error', onEnd) | ||
stream.once('close', cleanup) | ||
return defer | ||
function defer(fn) { | ||
done = fn | ||
} | ||
function onData(chunk) { | ||
@@ -46,3 +55,3 @@ buffers.push(chunk) | ||
err.limit = limit | ||
callback(err) | ||
done(err) | ||
cleanup() | ||
@@ -58,5 +67,5 @@ } | ||
err.expected = expected | ||
callback(err) | ||
done(err) | ||
} else { | ||
callback(null, Buffer.concat(buffers)) | ||
done(null, Buffer.concat(buffers)) | ||
} | ||
@@ -72,3 +81,3 @@ | ||
stream.removeListener('end', onEnd) | ||
stream.removeListener('error', callback) | ||
stream.removeListener('error', done) | ||
stream.removeListener('error', cleanup) | ||
@@ -75,0 +84,0 @@ stream.removeListener('close', cleanup) |
{ | ||
"name": "raw-body", | ||
"description": "Get and validate the raw body of a readable stream.", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"author": { | ||
@@ -21,7 +21,9 @@ "name": "Jonathan Ong", | ||
"devDependencies": { | ||
"mocha": "~1.12" | ||
"co": "*", | ||
"gnode": "*", | ||
"mocha": "*" | ||
}, | ||
"scripts": { | ||
"test": "make test" | ||
"test": "NODE=gnode make test" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
4997
66
3