through2
Advanced tools
Comparing version 0.5.1 to 0.6.0
{ | ||
"name": "through2", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise", | ||
@@ -23,11 +23,10 @@ "main": "through2.js", | ||
"dependencies": { | ||
"readable-stream": "~1.0.17", | ||
"xtend": "~3.0.0" | ||
"readable-stream": ">=1.0.27-1 <1.1.0-0", | ||
"xtend": ">=4.0.0 <4.1.0-0" | ||
}, | ||
"devDependencies": { | ||
"tape": "~2.3.0", | ||
"bl": "~0.6.0", | ||
"stream-spigot": "~3.0.1", | ||
"brtapsauce": "~0.2.2" | ||
"bl": ">=0.9.0 <0.10.0-0", | ||
"stream-spigot": ">=3.0.4 <3.1.0-0", | ||
"tape": ">=2.14.0 <2.15.0-0" | ||
} | ||
} |
@@ -103,4 +103,6 @@ # through2 | ||
If you **do not provide a `transformFunction`** then you will get a simple simple pass-through stream. | ||
Alternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error. | ||
If you **do not provide a `transformFunction`** then you will get a simple pass-through stream. | ||
### flushFunction | ||
@@ -107,0 +109,0 @@ |
@@ -5,3 +5,21 @@ var Transform = require('readable-stream/transform') | ||
function DestroyableTransform(opts) { | ||
Transform.call(this, opts) | ||
this._destroyed = false | ||
} | ||
inherits(DestroyableTransform, Transform) | ||
DestroyableTransform.destroy = function(err) { | ||
if (this._destroyed) return | ||
this._destroyed = true | ||
var self = this | ||
process.nextTick(function() { | ||
if (err) | ||
self.emit('error', err) | ||
self.emit('close') | ||
}) | ||
} | ||
// a noop _transform function | ||
@@ -36,3 +54,3 @@ function noop (chunk, enc, callback) { | ||
module.exports = through2(function (options, transform, flush) { | ||
var t2 = new Transform(options) | ||
var t2 = new DestroyableTransform(options) | ||
@@ -57,6 +75,6 @@ t2._transform = transform | ||
Transform.call(this, this.options) | ||
DestroyableTransform.call(this, this.options) | ||
} | ||
inherits(Through2, Transform) | ||
inherits(Through2, DestroyableTransform) | ||
@@ -73,3 +91,3 @@ Through2.prototype._transform = transform | ||
module.exports.obj = through2(function (options, transform, flush) { | ||
var t2 = new Transform(xtend({ objectMode: true, highWaterMark: 16 }, options)) | ||
var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options)) | ||
@@ -76,0 +94,0 @@ t2._transform = transform |
10349
3
68
143
+ Addedxtend@4.0.2(transitive)
- Removedxtend@3.0.0(transitive)
Updatedxtend@>=4.0.0 <4.1.0-0