bufferedstream
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -0,1 +1,6 @@ | ||
= 3.0.5 / 2014-12-22 | ||
* Update bodec dependency for browsers | ||
* Removed dependency on d | ||
= 3.0.3 / 2014-12-18 | ||
@@ -2,0 +7,0 @@ |
/* jshint -W084 */ | ||
var d = require('d'); | ||
var EventEmitter = require('events').EventEmitter; | ||
@@ -151,3 +150,5 @@ var isBinary = require('./utils/isBinary'); | ||
constructor: d(BufferedStream), | ||
constructor: { | ||
value: BufferedStream | ||
}, | ||
@@ -157,5 +158,7 @@ /** | ||
*/ | ||
empty: d.gs(function () { | ||
return this._chunks == null || this._chunks.length === 0; | ||
}), | ||
empty: { | ||
get: function () { | ||
return this._chunks == null || this._chunks.length === 0; | ||
} | ||
}, | ||
@@ -165,5 +168,7 @@ /** | ||
*/ | ||
full: d.gs(function () { | ||
return this.maxSize < this.size; | ||
}), | ||
full: { | ||
get: function () { | ||
return this.maxSize < this.size; | ||
} | ||
}, | ||
@@ -174,5 +179,7 @@ /** | ||
*/ | ||
piped: d.gs(function () { | ||
return this._source != null; | ||
}), | ||
piped: { | ||
get: function () { | ||
return this._source != null; | ||
} | ||
}, | ||
@@ -185,5 +192,7 @@ /** | ||
*/ | ||
setEncoding: d(function (encoding) { | ||
this.encoding = encoding; | ||
}), | ||
setEncoding: { | ||
value: function (encoding) { | ||
this.encoding = encoding; | ||
} | ||
}, | ||
@@ -194,5 +203,7 @@ /** | ||
*/ | ||
pause: d(function () { | ||
this.paused = true; | ||
}), | ||
pause: { | ||
value: function () { | ||
this.paused = true; | ||
} | ||
}, | ||
@@ -202,8 +213,10 @@ /** | ||
*/ | ||
resume: d(function () { | ||
if (this.paused) | ||
flushSoon(this); | ||
resume: { | ||
value: function () { | ||
if (this.paused) | ||
flushSoon(this); | ||
this.paused = false; | ||
}), | ||
this.paused = false; | ||
} | ||
}, | ||
@@ -218,67 +231,69 @@ /** | ||
*/ | ||
pipe: d(function (dest, options) { | ||
var source = this; | ||
pipe: { | ||
value: function (dest, options) { | ||
var source = this; | ||
function ondata(chunk) { | ||
if (dest.writable && false === dest.write(chunk)) | ||
source.pause(); | ||
} | ||
function ondata(chunk) { | ||
if (dest.writable && false === dest.write(chunk)) | ||
source.pause(); | ||
} | ||
source.on('data', ondata); | ||
source.on('data', ondata); | ||
function ondrain() { | ||
if (source.readable) | ||
source.resume(); | ||
} | ||
function ondrain() { | ||
if (source.readable) | ||
source.resume(); | ||
} | ||
dest.on('drain', ondrain); | ||
dest.on('drain', ondrain); | ||
var didOnEnd = false; | ||
function onend() { | ||
if (didOnEnd) return; | ||
didOnEnd = true; | ||
var didOnEnd = false; | ||
function onend() { | ||
if (didOnEnd) return; | ||
didOnEnd = true; | ||
dest.end(); | ||
} | ||
dest.end(); | ||
} | ||
// If the 'end' option is not supplied, dest.end() will be called when | ||
// source gets the 'end' or 'close' events. Only dest.end() once. | ||
if (!dest._isStdio && (!options || options.end !== false)) | ||
source.on('end', onend); | ||
// If the 'end' option is not supplied, dest.end() will be called when | ||
// source gets the 'end' or 'close' events. Only dest.end() once. | ||
if (!dest._isStdio && (!options || options.end !== false)) | ||
source.on('end', onend); | ||
// don't leave dangling pipes when there are errors. | ||
function onerror(error) { | ||
cleanup(); | ||
if (EventEmitter.listenerCount(this, 'error') === 0) | ||
throw error; // Unhandled stream error in pipe. | ||
} | ||
// don't leave dangling pipes when there are errors. | ||
function onerror(error) { | ||
cleanup(); | ||
if (EventEmitter.listenerCount(this, 'error') === 0) | ||
throw error; // Unhandled stream error in pipe. | ||
} | ||
source.on('error', onerror); | ||
dest.on('error', onerror); | ||
source.on('error', onerror); | ||
dest.on('error', onerror); | ||
// remove all the event listeners that were added. | ||
function cleanup() { | ||
source.removeListener('data', ondata); | ||
dest.removeListener('drain', ondrain); | ||
// remove all the event listeners that were added. | ||
function cleanup() { | ||
source.removeListener('data', ondata); | ||
dest.removeListener('drain', ondrain); | ||
source.removeListener('end', onend); | ||
source.removeListener('end', onend); | ||
source.removeListener('error', onerror); | ||
dest.removeListener('error', onerror); | ||
source.removeListener('error', onerror); | ||
dest.removeListener('error', onerror); | ||
source.removeListener('end', cleanup); | ||
} | ||
source.removeListener('end', cleanup); | ||
} | ||
source.on('end', cleanup); | ||
dest.on('close', cleanup); | ||
source.on('end', cleanup); | ||
dest.on('close', cleanup); | ||
dest.emit('pipe', source); | ||
dest.emit('pipe', source); | ||
// Mimic the behavior of node v2 streams where pipe() resumes the flow. | ||
// This lets us avoid having to do stream.resume() all over the place. | ||
source.resume(); | ||
// Mimic the behavior of node v2 streams where pipe() resumes the flow. | ||
// This lets us avoid having to do stream.resume() all over the place. | ||
source.resume(); | ||
// Allow for unix-like usage: A.pipe(B).pipe(C) | ||
return dest; | ||
}), | ||
// Allow for unix-like usage: A.pipe(B).pipe(C) | ||
return dest; | ||
} | ||
}, | ||
@@ -290,25 +305,27 @@ /** | ||
*/ | ||
write: d(function (chunk) { | ||
if (!this.writable) | ||
throw new Error('BufferedStream is not writable'); | ||
write: { | ||
value: function (chunk) { | ||
if (!this.writable) | ||
throw new Error('BufferedStream is not writable'); | ||
if (this.ended) | ||
throw new Error('BufferedStream is already ended'); | ||
if (this.ended) | ||
throw new Error('BufferedStream is already ended'); | ||
if (!isBinary(chunk)) | ||
chunk = binaryFrom(chunk, arguments[1]); | ||
if (!isBinary(chunk)) | ||
chunk = binaryFrom(chunk, arguments[1]); | ||
this._chunks.push(chunk); | ||
this.size += chunk.length; | ||
this._chunks.push(chunk); | ||
this.size += chunk.length; | ||
flushSoon(this); | ||
flushSoon(this); | ||
if (this.full) { | ||
this._wasFull = true; | ||
return false; | ||
if (this.full) { | ||
this._wasFull = true; | ||
return false; | ||
} | ||
return true; | ||
} | ||
}, | ||
return true; | ||
}), | ||
/** | ||
@@ -319,15 +336,17 @@ * Writes the given chunk to this stream and queues the end event to be | ||
*/ | ||
end: d(function (chunk) { | ||
if (this.ended) | ||
throw new Error('BufferedStream is already ended'); | ||
end: { | ||
value: function (chunk) { | ||
if (this.ended) | ||
throw new Error('BufferedStream is already ended'); | ||
if (chunk != null) | ||
this.write(chunk, arguments[1]); | ||
if (chunk != null) | ||
this.write(chunk, arguments[1]); | ||
this.ended = true; | ||
this.ended = true; | ||
// Trigger the flush cycle one last time to emit | ||
// any data that was written before end was called. | ||
flushSoon(this); | ||
}) | ||
// Trigger the flush cycle one last time to emit | ||
// any data that was written before end was called. | ||
flushSoon(this); | ||
} | ||
} | ||
@@ -334,0 +353,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"author": "Michael Jackson", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"repository": { | ||
@@ -21,4 +21,3 @@ "type": "git", | ||
"dependencies": { | ||
"bodec": "git://github.com/creationix/bodec#29168738", | ||
"d": "~0.1.1", | ||
"bodec": "git://github.com/mjackson/bodec#browser", | ||
"events": "~1.0.1" | ||
@@ -25,0 +24,0 @@ }, |
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
16877
2
10725
341
- Removedd@~0.1.1
- Removedd@0.1.11.0.2(transitive)
- Removedes5-ext@0.10.64(transitive)
- Removedes6-iterator@2.0.3(transitive)
- Removedes6-symbol@3.1.4(transitive)
- Removedesniff@2.0.1(transitive)
- Removedevent-emitter@0.3.5(transitive)
- Removedext@1.7.0(transitive)
- Removednext-tick@1.1.0(transitive)
- Removedtype@2.7.3(transitive)