Comparing version 1.2.0 to 1.2.1
@@ -106,6 +106,4 @@ (function () { | ||
onEnd(); | ||
} else if (writeError && readError) { | ||
}else if (writeError && end) { | ||
onEnd(); | ||
} else if (writeError && end) { | ||
onEnd(); | ||
} else if (writeError && isGunzip) { | ||
@@ -194,3 +192,3 @@ onEnd(); | ||
readStream.on('data', onData); | ||
readStream.on('error', onError); | ||
readStream.on('error', onEnd); | ||
readStream.on('end', onEnd); | ||
@@ -202,9 +200,5 @@ | ||
function onError(e) { | ||
error = e ; | ||
} | ||
function onEnd() { | ||
function onEnd(error) { | ||
readStream.removeListener('data', onData); | ||
readStream.removeListener('error', onError); | ||
readStream.removeListener('error', onEnd); | ||
readStream.removeListener('end', onEnd); | ||
@@ -211,0 +205,0 @@ |
{ | ||
"name": "pipe-io", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -16,3 +16,5 @@ "description": "Pipe streams and handle events", | ||
"scripts": { | ||
"test": "tape test/*.js" | ||
"test": "tape test/*.js", | ||
"coverage": "nyc npm test", | ||
"report": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
@@ -26,4 +28,6 @@ "dependencies": {}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.6", | ||
"nyc": "^5.0.1", | ||
"tape": "^4.2.0" | ||
} | ||
} |
@@ -33,2 +33,11 @@ (function() { | ||
test('getBody: error', function(t) { | ||
var read = fs.createReadStream(String(Math.random())); | ||
pipe.getBody(read, function(error) { | ||
t.ok(error, 'read error: ' + error.message); | ||
t.end(); | ||
}); | ||
}); | ||
test('file1 | file2: no error', function(t) { | ||
@@ -197,2 +206,37 @@ var tmp = os.tmpdir(), | ||
test('file1, file2 | options: empty object', function(t) { | ||
var server = http.createServer(function (req, res) { | ||
var read1 = fs.createReadStream(__filename), | ||
read2 = fs.createReadStream(__filename); | ||
pipe([read1, res], {}, function() { | ||
pipe([read2, res], function() { | ||
}); | ||
}); | ||
}); | ||
server.listen(7331, '127.0.0.1', function() { | ||
console.log('server: 127.0.0.1:7331'); | ||
http.get('http://127.0.0.1:7331', function(res) { | ||
console.log('request: http://127.0.0.1:7331'); | ||
pipe.getBody(res, function(error, data) { | ||
var file = fs.readFileSync(__filename, 'utf8'); | ||
t.equal(data, file, 'reponse == file1 + file2'); | ||
t.end(); | ||
server.close(); | ||
}); | ||
}).on('error', function(error) { | ||
t.ok(error, error.message); | ||
t.end(); | ||
}); | ||
}); | ||
server.on('error', function(error) { | ||
t.ok(error, error.message); | ||
t.end(); | ||
}); | ||
}); | ||
function tryPipe(from, to, fn) { | ||
@@ -199,0 +243,0 @@ var read = fs.createReadStream(from), |
Sorry, the diff of this file is not supported yet
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
21428
385
3