mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(pipe) rm Util.exec
This commit is contained in:
parent
9b9e50efd1
commit
d5b50a9383
1 changed files with 6 additions and 8 deletions
|
|
@ -25,7 +25,7 @@
|
|||
* @param callback - function(error) {}
|
||||
*/
|
||||
function create(read, write, options, callback) {
|
||||
var gzip, isFsWrite, func,
|
||||
var gzip, isFsWrite,
|
||||
isStrRead = type.string(read),
|
||||
isStrWrite = type.string(write),
|
||||
isFunc = type.function(options),
|
||||
|
|
@ -34,15 +34,13 @@
|
|||
bufferSize: 4 * 1024
|
||||
};
|
||||
|
||||
Util.checkArgs(arguments, ['read', 'write', 'options']);
|
||||
Util.checkArgs(arguments, ['read', 'write', 'callback']);
|
||||
|
||||
if (isFunc)
|
||||
callback = options;
|
||||
else
|
||||
o = options;
|
||||
|
||||
func = Util.exec.ret(callback);
|
||||
|
||||
if (options.range)
|
||||
Util.extend(optionsRead, {
|
||||
start : o.range.start,
|
||||
|
|
@ -64,19 +62,19 @@
|
|||
else
|
||||
gzip = zlib.createGunzip();
|
||||
|
||||
on('error', read, func);
|
||||
on('error', read, callback);
|
||||
read = read.pipe(gzip);
|
||||
}
|
||||
|
||||
on('error', write, func);
|
||||
on('error', read, func);
|
||||
on('error', write, callback);
|
||||
on('error', read, callback);
|
||||
|
||||
Util.exec.if(!isFsWrite, function() {
|
||||
read.pipe(write, {
|
||||
end: !o.notEnd
|
||||
});
|
||||
|
||||
on('end', read, func);
|
||||
on('end', read, callback);
|
||||
}, function(callback) {
|
||||
on('open', write, callback);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue