Socket
Socket
Sign inDemoInstall

pipe-io

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pipe-io - npm Package Compare versions

Comparing version 0.8.4 to 0.9.0

110

lib/pipe.js

@@ -13,60 +13,70 @@ (function () {

* create pipe
* params: {callback, read or from, write or to, gzip}
* read - readable stream
* write - writable stream
* to - name of file to write
* from - name of file to read
* gzip - should gzip to be used
* callback - function(error) {}
*
* @param params
* @param callback
*
* @param read - readable stream
* @param write - writable stream
*
* @param options {
* gzip
* ungzip
* notEnd
* }
*
* @param callback - function(error) {}
*/
function create(params) {
var gzip, read, write, isFsWrite,
p = params,
func = p.callback,
options = {
function create(read, write, options, callback) {
var gzip, isFsWrite, func,
isStrRead = Util.isString(read),
isStrWrite = Util.isString(write),
isFunc = Util.isFunction(options),
o = {},
optionsRead = {
bufferSize: 4 * 1024
};
if (p) {
if (p.range)
options = {
start : p.range.start,
end : p.range.end,
};
Util.checkArgs(arguments, ['read', 'write', 'options']);
if (isFunc)
callback = options;
else
o = options;
func = Util.exec.ret(callback);
if (options.range)
Util.extend(optionsRead, {
start : o.range.start,
end : o.range.end,
});
read = p.read || fs.createReadStream(p.from, options);
if (isStrRead)
read = fs.createReadStream(read, optionsRead);
if (isStrWrite) {
write = fs.createWriteStream(write);
isFsWrite = true;
}
if (o.gzip || o.gunzip) {
if (o.gzip)
gzip = zlib.createGzip();
else
gzip = zlib.createGunzip();
if (p.write)
write = p.write;
else {
write = fs.createWriteStream(p.to);
isFsWrite = true;
}
if (p.gzip || p.gunzip) {
if (p.gzip)
gzip = zlib.createGzip();
else
gzip = zlib.createGunzip();
on('error', read, func);
read = read.pipe(gzip);
}
on('error', write, func);
on('error', read, func);
read = read.pipe(gzip);
}
on('error', write, func);
on('error', read, func);
Util.exec.if(!isFsWrite, function() {
read.pipe(write, {
end: !o.notEnd
});
Util.exec.if(!isFsWrite, function() {
read.pipe(write, {
end: !p.notEnd
});
on('end', read, func);
}, function(callback) {
on('open', write, callback);
});
}
on('end', read, func);
}, function(callback) {
on('open', write, callback);
});
}

@@ -73,0 +83,0 @@

{
"name": "pipe-io",
"version": "0.8.4",
"version": "0.9.0",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

@@ -5,0 +5,0 @@ "description": "Pipe streams and handle events",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc