Comparing version 2.0.2 to 2.0.3
'use strict'; | ||
var fs = require('fs'); | ||
var zlib = require('zlib'); | ||
@@ -56,20 +55,12 @@ var assert = require('assert'); | ||
callWhenOpen(write, function (e) { | ||
if (e) { | ||
onWriteError(e); | ||
read.on('readable', function () { | ||
read.resume(); | ||
}); | ||
} | ||
if (end && readError) | ||
{ return onEnd(); } | ||
open = true; | ||
write.on('error', onWriteError); | ||
setListeners(streams, onError); | ||
fullPipe(allStreams, options); | ||
read.on('readable', function () { | ||
read.resume(); | ||
}); | ||
open = true; | ||
write.on('error', onWriteError); | ||
setListeners(streams, onError); | ||
fullPipe(allStreams, options); | ||
function onWriteError(error) { | ||
@@ -88,3 +79,3 @@ writeError = true; | ||
} | ||
function onReadEnd() { | ||
@@ -94,3 +85,3 @@ end = true; | ||
} | ||
function onWriteFinish() { | ||
@@ -135,29 +126,2 @@ finish = true; | ||
/* | ||
* when stream is fs.WriteStream | ||
* finish event could be emitted before | ||
* open and then everything crash | ||
*/ | ||
function callWhenOpen(stream, fn) { | ||
var isFsWrite = stream instanceof fs.WriteStream; | ||
var on = function (error) { | ||
var isError = error instanceof Error; | ||
stream.removeListener('open', on); | ||
stream.removeListener('error', on); | ||
if (isError) | ||
{ fn(error); } | ||
else | ||
{ fn(); } | ||
}; | ||
if (!isFsWrite) { | ||
fn(); | ||
} else { | ||
stream.on('open', on); | ||
stream.on('error', on); | ||
} | ||
} | ||
function fullPipe(streams, options) { | ||
@@ -164,0 +128,0 @@ var main; |
'use strict'; | ||
const fs = require('fs'); | ||
const zlib = require('zlib'); | ||
@@ -56,20 +55,12 @@ const assert = require('assert'); | ||
callWhenOpen(write, (e) => { | ||
if (e) { | ||
onWriteError(e); | ||
read.on('readable', () => { | ||
read.resume(); | ||
}); | ||
} | ||
if (end && readError) | ||
return onEnd(); | ||
open = true; | ||
write.on('error', onWriteError); | ||
setListeners(streams, onError); | ||
fullPipe(allStreams, options); | ||
read.on('readable', () => { | ||
read.resume(); | ||
}); | ||
open = true; | ||
write.on('error', onWriteError); | ||
setListeners(streams, onError); | ||
fullPipe(allStreams, options); | ||
function onWriteError(error) { | ||
@@ -88,3 +79,3 @@ writeError = true; | ||
} | ||
function onReadEnd() { | ||
@@ -94,3 +85,3 @@ end = true; | ||
} | ||
function onWriteFinish() { | ||
@@ -135,29 +126,2 @@ finish = true; | ||
/* | ||
* when stream is fs.WriteStream | ||
* finish event could be emitted before | ||
* open and then everything crash | ||
*/ | ||
function callWhenOpen(stream, fn) { | ||
const isFsWrite = stream instanceof fs.WriteStream; | ||
const on = (error) => { | ||
const isError = error instanceof Error; | ||
stream.removeListener('open', on); | ||
stream.removeListener('error', on); | ||
if (isError) | ||
fn(error); | ||
else | ||
fn(); | ||
}; | ||
if (!isFsWrite) { | ||
fn(); | ||
} else { | ||
stream.on('open', on); | ||
stream.on('error', on); | ||
} | ||
} | ||
function fullPipe(streams, options) { | ||
@@ -164,0 +128,0 @@ let main; |
{ | ||
"name": "pipe-io", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -38,5 +38,5 @@ "description": "Pipe streams and handle events", | ||
"coveralls": "^2.11.6", | ||
"eslint": "^3.8.1", | ||
"eslint": "^4.0.0", | ||
"nodemon": "^1.11.0", | ||
"nyc": "^10.0.0", | ||
"nyc": "^11.0.2", | ||
"pullout": "^1.0.1", | ||
@@ -43,0 +43,0 @@ "redrun": "^5.9.2", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
15342
241