through2 2.0.4 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://nodei.co/npm/through2/)
|
|
4
4
|
|
|
5
|
-
**A tiny wrapper around Node streams.Transform (Streams2/3) to avoid explicit subclassing noise**
|
|
5
|
+
**A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise**
|
|
6
6
|
|
|
7
7
|
Inspired by [Dominic Tarr](https://github.com/dominictarr)'s [through](https://github.com/dominictarr/through) in that it's so much easier to make a stream out of a function than it is to set up the prototype chain properly: `through(function (chunk) { ... })`.
|
|
8
8
|
|
|
9
|
-
Note:
|
|
9
|
+
***Note: Users of Node.js 0.10 and 0.12 should install `through2@2.x`. As of through2@3.x, readable-stream@3 is being used and is not compatible with older versions of Node.js.*** _v2.x support is being maintained on the [v2.x](https://github.com/rvagg/through2/tree/v2.x) branch._
|
|
10
10
|
|
|
11
11
|
```js
|
|
12
12
|
fs.createReadStream('ex.txt')
|
|
@@ -54,7 +54,7 @@ Note that `through2.obj(fn)` is a convenience wrapper around `through2({ objectM
|
|
|
54
54
|
|
|
55
55
|
<b><code>through2([ options, ] [ transformFunction ] [, flushFunction ])</code></b>
|
|
56
56
|
|
|
57
|
-
Consult the **[stream.Transform](
|
|
57
|
+
Consult the **[stream.Transform](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform)** documentation for the exact rules of the `transformFunction` (i.e. `this._transform`) and the optional `flushFunction` (i.e. `this._flush`).
|
|
58
58
|
|
|
59
59
|
### options
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ fs.createReadStream('/tmp/important.dat')
|
|
|
69
69
|
cb(null, 'wut?') // note we can use the second argument on the callback
|
|
70
70
|
// to provide data as an alternative to this.push('wut?')
|
|
71
71
|
}
|
|
72
|
-
)
|
|
72
|
+
))
|
|
73
73
|
.pipe(fs.createWriteStream('/tmp/wut.txt'))
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -131,4 +131,4 @@ var converter = FToC({objectMode: true})
|
|
|
131
131
|
|
|
132
132
|
## License
|
|
133
133
|
|
|
134
|
-
**through2** is Copyright (c) Rod Vagg
|
|
134
|
+
**through2** is Copyright (c) Rod Vagg and additional contributors and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "through2",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A tiny wrapper around Node
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"description": "A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise",
|
|
5
5
|
"main": "through2.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "nyc node test/test.js | faucet && nyc report"
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"author": "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"inherits": "^2.0.4",
|
|
23
|
+
"readable-stream": "2 || 3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"bl": "~2.0.1",
|
package/through2.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
var Transform = require('readable-stream').Transform
|
|
2
|
-
, inherits = require('
|
|
3
|
-
, xtend = require('xtend')
|
|
2
|
+
, inherits = require('inherits')
|
|
4
3
|
|
|
5
4
|
function DestroyableTransform(opts) {
|
|
6
5
|
Transform.call(this, opts)
|
|
@@ -68,7 +67,7 @@ module.exports.ctor = through2(function (options, transform, flush) {
|
|
|
68
67
|
if (!(this instanceof Through2))
|
|
69
68
|
return new Through2(override)
|
|
70
69
|
|
|
71
|
-
this.options =
|
|
70
|
+
this.options = Object.assign({}, options, override)
|
|
72
71
|
|
|
73
72
|
DestroyableTransform.call(this, this.options)
|
|
74
73
|
}
|
|
@@ -85,7 +84,7 @@ module.exports.ctor = through2(function (options, transform, flush) {
|
|
|
85
84
|
|
|
86
85
|
|
|
87
86
|
module.exports.obj = through2(function (options, transform, flush) {
|
|
88
|
-
var t2 = new DestroyableTransform(
|
|
87
|
+
var t2 = new DestroyableTransform(Object.assign({ objectMode: true, highWaterMark: 16 }, options))
|
|
89
88
|
|
|
90
89
|
t2._transform = transform
|
|
91
90
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"/Users/rvagg/git/through2/through2.js":{"path":"/Users/rvagg/git/through2/through2.js","statementMap":{"0":{"start":{"line":1,"column":16},"end":{"line":1,"column":52}},"1":{"start":{"line":2,"column":16},"end":{"line":2,"column":40}},"2":{"start":{"line":3,"column":16},"end":{"line":3,"column":32}},"3":{"start":{"line":6,"column":2},"end":{"line":6,"column":28}},"4":{"start":{"line":7,"column":2},"end":{"line":7,"column":25}},"5":{"start":{"line":10,"column":0},"end":{"line":10,"column":41}},"6":{"start":{"line":12,"column":0},"end":{"line":22,"column":1}},"7":{"start":{"line":13,"column":2},"end":{"line":13,"column":29}},"8":{"start":{"line":13,"column":23},"end":{"line":13,"column":29}},"9":{"start":{"line":14,"column":2},"end":{"line":14,"column":24}},"10":{"start":{"line":16,"column":13},"end":{"line":16,"column":17}},"11":{"start":{"line":17,"column":2},"end":{"line":21,"column":4}},"12":{"start":{"line":18,"column":4},"end":{"line":19,"column":29}},"13":{"start":{"line":19,"column":6},"end":{"line":19,"column":29}},"14":{"start":{"line":20,"column":4},"end":{"line":20,"column":22}},"15":{"start":{"line":26,"column":2},"end":{"line":26,"column":23}},"16":{"start":{"line":33,"column":2},"end":{"line":47,"column":3}},"17":{"start":{"line":34,"column":4},"end":{"line":38,"column":5}},"18":{"start":{"line":35,"column":6},"end":{"line":35,"column":27}},"19":{"start":{"line":36,"column":6},"end":{"line":36,"column":25}},"20":{"start":{"line":37,"column":6},"end":{"line":37,"column":20}},"21":{"start":{"line":40,"column":4},"end":{"line":41,"column":22}},"22":{"start":{"line":41,"column":6},"end":{"line":41,"column":22}},"23":{"start":{"line":43,"column":4},"end":{"line":44,"column":18}},"24":{"start":{"line":44,"column":6},"end":{"line":44,"column":18}},"25":{"start":{"line":46,"column":4},"end":{"line":46,"column":47}},"26":{"start":{"line":52,"column":0},"end":{"line":61,"column":2}},"27":{"start":{"line":53,"column":11},"end":{"line":53,"column":44}},"28":{"start":{"line":55,"column":2},"end":{"line":55,"column":27}},"29":{"start":{"line":57,"column":2},"end":{"line":58,"column":21}},"30":{"start":{"line":58,"column":4},"end":{"line":58,"column":21}},"31":{"start":{"line":60,"column":2},"end":{"line":60,"column":11}},"32":{"start":{"line":66,"column":0},"end":{"line":84,"column":2}},"33":{"start":{"line":68,"column":4},"end":{"line":69,"column":35}},"34":{"start":{"line":69,"column":6},"end":{"line":69,"column":35}},"35":{"start":{"line":71,"column":4},"end":{"line":71,"column":43}},"36":{"start":{"line":73,"column":4},"end":{"line":73,"column":49}},"37":{"start":{"line":76,"column":2},"end":{"line":76,"column":42}},"38":{"start":{"line":78,"column":2},"end":{"line":78,"column":43}},"39":{"start":{"line":80,"column":2},"end":{"line":81,"column":37}},"40":{"start":{"line":81,"column":4},"end":{"line":81,"column":37}},"41":{"start":{"line":83,"column":2},"end":{"line":83,"column":17}},"42":{"start":{"line":87,"column":0},"end":{"line":96,"column":2}},"43":{"start":{"line":88,"column":11},"end":{"line":88,"column":92}},"44":{"start":{"line":90,"column":2},"end":{"line":90,"column":27}},"45":{"start":{"line":92,"column":2},"end":{"line":93,"column":21}},"46":{"start":{"line":93,"column":4},"end":{"line":93,"column":21}},"47":{"start":{"line":95,"column":2},"end":{"line":95,"column":11}}},"fnMap":{"0":{"name":"DestroyableTransform","decl":{"start":{"line":5,"column":9},"end":{"line":5,"column":29}},"loc":{"start":{"line":5,"column":36},"end":{"line":8,"column":1}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":12,"column":41},"end":{"line":12,"column":42}},"loc":{"start":{"line":12,"column":55},"end":{"line":22,"column":1}},"line":12},"2":{"name":"(anonymous_2)","decl":{"start":{"line":17,"column":19},"end":{"line":17,"column":20}},"loc":{"start":{"line":17,"column":30},"end":{"line":21,"column":3}},"line":17},"3":{"name":"noop","decl":{"start":{"line":25,"column":9},"end":{"line":25,"column":13}},"loc":{"start":{"line":25,"column":37},"end":{"line":27,"column":1}},"line":25},"4":{"name":"through2","decl":{"start":{"line":32,"column":9},"end":{"line":32,"column":17}},"loc":{"start":{"line":32,"column":30},"end":{"line":48,"column":1}},"line":32},"5":{"name":"(anonymous_5)","decl":{"start":{"line":33,"column":9},"end":{"line":33,"column":10}},"loc":{"start":{"line":33,"column":46},"end":{"line":47,"column":3}},"line":33},"6":{"name":"(anonymous_6)","decl":{"start":{"line":52,"column":26},"end":{"line":52,"column":27}},"loc":{"start":{"line":52,"column":63},"end":{"line":61,"column":1}},"line":52},"7":{"name":"(anonymous_7)","decl":{"start":{"line":66,"column":31},"end":{"line":66,"column":32}},"loc":{"start":{"line":66,"column":68},"end":{"line":84,"column":1}},"line":66},"8":{"name":"Through2","decl":{"start":{"line":67,"column":11},"end":{"line":67,"column":19}},"loc":{"start":{"line":67,"column":31},"end":{"line":74,"column":3}},"line":67},"9":{"name":"(anonymous_9)","decl":{"start":{"line":87,"column":30},"end":{"line":87,"column":31}},"loc":{"start":{"line":87,"column":67},"end":{"line":96,"column":1}},"line":87}},"branchMap":{"0":{"loc":{"start":{"line":13,"column":2},"end":{"line":13,"column":29}},"type":"if","locations":[{"start":{"line":13,"column":2},"end":{"line":13,"column":29}},{"start":{"line":13,"column":2},"end":{"line":13,"column":29}}],"line":13},"1":{"loc":{"start":{"line":18,"column":4},"end":{"line":19,"column":29}},"type":"if","locations":[{"start":{"line":18,"column":4},"end":{"line":19,"column":29}},{"start":{"line":18,"column":4},"end":{"line":19,"column":29}}],"line":18},"2":{"loc":{"start":{"line":34,"column":4},"end":{"line":38,"column":5}},"type":"if","locations":[{"start":{"line":34,"column":4},"end":{"line":38,"column":5}},{"start":{"line":34,"column":4},"end":{"line":38,"column":5}}],"line":34},"3":{"loc":{"start":{"line":40,"column":4},"end":{"line":41,"column":22}},"type":"if","locations":[{"start":{"line":40,"column":4},"end":{"line":41,"column":22}},{"start":{"line":40,"column":4},"end":{"line":41,"column":22}}],"line":40},"4":{"loc":{"start":{"line":43,"column":4},"end":{"line":44,"column":18}},"type":"if","locations":[{"start":{"line":43,"column":4},"end":{"line":44,"column":18}},{"start":{"line":43,"column":4},"end":{"line":44,"column":18}}],"line":43},"5":{"loc":{"start":{"line":57,"column":2},"end":{"line":58,"column":21}},"type":"if","locations":[{"start":{"line":57,"column":2},"end":{"line":58,"column":21}},{"start":{"line":57,"column":2},"end":{"line":58,"column":21}}],"line":57},"6":{"loc":{"start":{"line":68,"column":4},"end":{"line":69,"column":35}},"type":"if","locations":[{"start":{"line":68,"column":4},"end":{"line":69,"column":35}},{"start":{"line":68,"column":4},"end":{"line":69,"column":35}}],"line":68},"7":{"loc":{"start":{"line":80,"column":2},"end":{"line":81,"column":37}},"type":"if","locations":[{"start":{"line":80,"column":2},"end":{"line":81,"column":37}},{"start":{"line":80,"column":2},"end":{"line":81,"column":37}}],"line":80},"8":{"loc":{"start":{"line":92,"column":2},"end":{"line":93,"column":21}},"type":"if","locations":[{"start":{"line":92,"column":2},"end":{"line":93,"column":21}},{"start":{"line":92,"column":2},"end":{"line":93,"column":21}}],"line":92}},"s":{"0":1,"1":1,"2":1,"3":16,"4":16,"5":1,"6":1,"7":3,"8":1,"9":2,"10":2,"11":2,"12":2,"13":0,"14":2,"15":0,"16":3,"17":15,"18":8,"19":8,"20":8,"21":15,"22":2,"23":15,"24":14,"25":15,"26":1,"27":6,"28":6,"29":6,"30":1,"31":6,"32":1,"33":16,"34":7,"35":9,"36":9,"37":8,"38":8,"39":8,"40":0,"41":8,"42":1,"43":1,"44":1,"45":1,"46":0,"47":1},"f":{"0":16,"1":3,"2":2,"3":0,"4":3,"5":15,"6":6,"7":8,"8":16,"9":1},"b":{"0":[1,2],"1":[0,2],"2":[8,7],"3":[2,13],"4":[14,1],"5":[1,5],"6":[7,9],"7":[0,8],"8":[0,1]},"_coverageSchema":"43e27e138ebf9cfc5966b082cf9a028302ed4184","hash":"408ccc0128141763d51fdc70aebad4c4e71c4370","contentHash":"e0da32c561a9d3fea08adc00c2d530c5"}}
|