refactor(pipe) lRead -> read

This commit is contained in:
coderaiser 2014-03-18 05:20:52 -04:00
parent 7d664f9227
commit cc2aab3b93

View file

@ -18,48 +18,48 @@
exports.getBody = getBody;
exports.create = function(pParams) {
var lZlib, lError, lMsg, lRead, lWrite, lIsFsWrite,
p = pParams;
exports.create = function(params) {
var gzip, onError, read, write, isFsWrite,
p = params;
if (p) {
lRead = p.read || fs.createReadStream(p.from, {
read = p.read || fs.createReadStream(p.from, {
bufferSize: 4 * 1024
});
if (p.write)
lWrite = p.write;
write = p.write;
else {
lWrite = fs.createWriteStream(p.to);
lIsFsWrite = true;
write = fs.createWriteStream(p.to);
isFsWrite = true;
}
lError = function(pError) {
Util.exec(p.callback, pError);
onError = function(error) {
Util.exec(p.callback, error);
};
if (p.gzip) {
lZlib = zlib.createGzip();
lRead.on('error', lError);
lRead = lRead.pipe(lZlib);
gzip = zlib.createGzip();
read.on('error', onError);
read = read.pipe(gzip);
}
lWrite.on('error', lError);
lRead.on('error', lError);
write.on('error', onError);
read.on('error', onError);
Util.ifExec(!lIsFsWrite, function() {
lRead.on('data', function(data) {
lWrite.write(data);
Util.ifExec(!isFsWrite, function() {
read.on('data', function(data) {
write.write(data);
});
lRead.on('end', function() {
read.on('end', function() {
if (!p.notEnd)
lWrite.end();
write.end();
Util.exec(p.callback);
});
}, function(pCallBack) {
lWrite.on('open', pCallBack);
}, function(callback) {
write.on('open', callback);
});
}
};