Socket
Socket
Sign inDemoInstall

through2

Package Overview
Dependencies
6
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

13

package.json
{
"name": "through2",
"version": "1.0.0",
"version": "1.1.0",
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",

@@ -23,10 +23,9 @@ "main": "through2.js",

"dependencies": {
"readable-stream": "~1.1.10",
"xtend": "~2.1.1"
"readable-stream": ">=1.1.13-1 <1.2.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"
},

@@ -33,0 +32,0 @@ "publishConfig": {

@@ -13,3 +13,3 @@ # through2

[![NPM](https://nodei.co/npm/through2.png?compact=true)](https://nodei.co/npm/through2/)
[![NPM](https://nodei.co/npm/through2.png?compact=true)](https://nodei.co/npm/through2/)

@@ -27,2 +27,4 @@ <!--

Note: A **Streams3** version of through2 is available in npm with the tag `"1.0"` rather than `"latest"` so an `npm install through2` will get you the current Streams2 version (version number is 0.x.x). To use a Streams3 version use `npm install through2@1` to fetch the latest version 1.x.x. More information about Streams2 vs Streams3 and recommendations [here](http://www.nearform.com/nodecrunch/dont-use-nodes-core-stream-module).
```js

@@ -37,3 +39,3 @@ fs.createReadStream('ex.txt')

this.push(chunk)
callback()

@@ -59,5 +61,5 @@

}
this.push(data)
callback()

@@ -105,4 +107,6 @@

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

@@ -134,4 +138,11 @@

## See Also
- [through2-map](https://github.com/brycebaril/through2-map) - Array.prototype.map analog for streams.
- [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams.
- [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams.
- [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies.
## License
**through2** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

@@ -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 }, options))
var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))

@@ -76,0 +94,0 @@ t2._transform = transform

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc