through2 1.1.1 → 2.0.3

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/LICENSE.html ADDED
@@ -0,0 +1,336 @@
1
+ <!doctype html>
2
+ <!-- Created with GFM2HTML: https://github.com/rvagg/gfm2html -->
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+ <title></title>
8
+ <meta name="description" content="">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+ <meta name="created-with" content="https://github.com/rvagg/gfm2html">
11
+
12
+ <style type="text/css">
13
+ /* most of normalize.css */
14
+ article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}[hidden],template{display:none;}html{font-family:sans-serif;/*1*/-ms-text-size-adjust:100%;/*2*/-webkit-text-size-adjust:100%;/*2*/}body{margin:0;}a{background:transparent;}a:focus{outline:thindotted;}a:active,a:hover{outline:0;}h1{font-size:2em;margin:0.67em0;}abbr[title]{border-bottom:1pxdotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;}mark{background:#ff0;color:#000;}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;}pre{white-space:pre-wrap;}q{quotes:"\201C""\201D""\2018""\2019";}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}table{border-collapse:collapse;border-spacing:0;}
15
+
16
+ html {
17
+ font: 14px 'Helvetica Neue', Helvetica, arial, freesans, clean, sans-serif;
18
+ }
19
+
20
+ .container {
21
+ line-height: 1.6;
22
+ color: #333;
23
+ background: #eee;
24
+ border-radius: 3px;
25
+ padding: 3px;
26
+ width: 790px;
27
+ margin: 10px auto;
28
+ }
29
+
30
+ .body-content {
31
+ background-color: #fff;
32
+ border: 1px solid #CACACA;
33
+ padding: 30px;
34
+ }
35
+
36
+ .body-content > *:first-child {
37
+ margin-top: 0 !important;
38
+ }
39
+
40
+ a, a:visited {
41
+ color: #4183c4;
42
+ text-decoration: none;
43
+ }
44
+
45
+ a:hover {
46
+ text-decoration: underline;
47
+ }
48
+
49
+ p, blockquote, ul, ol, dl, table, pre {
50
+ margin: 15px 0;
51
+ }
52
+
53
+ .markdown-body h1
54
+ , .markdown-body h2
55
+ , .markdown-body h3
56
+ , .markdown-body h4
57
+ , .markdown-body h5
58
+ , .markdown-body h6 {
59
+ margin: 20px 0 10px;
60
+ padding: 0;
61
+ font-weight: bold;
62
+ }
63
+
64
+ h1 {
65
+ font-size: 2.5em;
66
+ color: #000;
67
+ border-bottom: 1px solid #ddd;
68
+ }
69
+
70
+ h2 {
71
+ font-size: 2em;
72
+ border-bottom: 1px solid #eee;
73
+ color: #000;
74
+ }
75
+
76
+ img {
77
+ max-width: 100%;
78
+ }
79
+
80
+ hr {
81
+ background: transparent url("/img/hr.png") repeat-x 0 0;
82
+ border: 0 none;
83
+ color: #ccc;
84
+ height: 4px;
85
+ padding: 0;
86
+ }
87
+
88
+ table {
89
+ border-collapse: collapse;
90
+ border-spacing: 0;
91
+ }
92
+
93
+ tr:nth-child(2n) {
94
+ background-color: #f8f8f8;
95
+ }
96
+
97
+ .markdown-body tr {
98
+ border-top: 1px solid #ccc;
99
+ background-color: #fff;
100
+ }
101
+
102
+ td, th {
103
+ border: 1px solid #ccc;
104
+ padding: 6px 13px;
105
+ }
106
+
107
+ th {
108
+ font-weight: bold;
109
+ }
110
+
111
+ blockquote {
112
+ border-left: 4px solid #ddd;
113
+ padding: 0 15px;
114
+ color: #777;
115
+ }
116
+
117
+ blockquote > :last-child, blockquote > :first-child {
118
+ margin-bottom: 0px;
119
+ }
120
+
121
+ pre, code {
122
+ font-size: 13px;
123
+ font-family: 'UbuntuMono', monospace;
124
+ white-space: nowrap;
125
+ margin: 0 2px;
126
+ padding: 0px 5px;
127
+ border: 1px solid #eaeaea;
128
+ background-color: #f8f8f8;
129
+ border-radius: 3px;
130
+ }
131
+
132
+ pre > code {
133
+ white-space: pre;
134
+ }
135
+
136
+ pre {
137
+ overflow-x: auto;
138
+ white-space: pre;
139
+ padding: 10px;
140
+ line-height: 150%;
141
+ background-color: #f8f8f8;
142
+ border-color: #ccc;
143
+ }
144
+
145
+ pre code, pre tt {
146
+ margin: 0;
147
+ padding: 0;
148
+ border: 0;
149
+ background-color: transparent;
150
+ border: none;
151
+ }
152
+
153
+ .highlight .c
154
+ , .highlight .cm
155
+ , .highlight .cp
156
+ , .highlight .c1 {
157
+ color:#999988;
158
+ font-style:italic;
159
+ }
160
+
161
+ .highlight .err {
162
+ color:#a61717;
163
+ background-color:#e3d2d2
164
+ }
165
+
166
+ .highlight .o
167
+ , .highlight .gs
168
+ , .highlight .kc
169
+ , .highlight .kd
170
+ , .highlight .kn
171
+ , .highlight .kp
172
+ , .highlight .kr {
173
+ font-weight:bold
174
+ }
175
+
176
+ .highlight .cs {
177
+ color:#999999;
178
+ font-weight:bold;
179
+ font-style:italic
180
+ }
181
+
182
+ .highlight .gd {
183
+ color:#000000;
184
+ background-color:#ffdddd
185
+ }
186
+
187
+ .highlight .gd .x {
188
+ color:#000000;
189
+ background-color:#ffaaaa
190
+ }
191
+
192
+ .highlight .ge {
193
+ font-style:italic
194
+ }
195
+
196
+ .highlight .gr
197
+ , .highlight .gt {
198
+ color:#aa0000
199
+ }
200
+
201
+ .highlight .gh
202
+ , .highlight .bp {
203
+ color:#999999
204
+ }
205
+
206
+ .highlight .gi {
207
+ color:#000000;
208
+ background-color:#ddffdd
209
+ }
210
+
211
+ .highlight .gi .x {
212
+ color:#000000;
213
+ background-color:#aaffaa
214
+ }
215
+
216
+ .highlight .go {
217
+ color:#888888
218
+ }
219
+
220
+ .highlight .gp
221
+ , .highlight .nn {
222
+ color:#555555
223
+ }
224
+
225
+
226
+ .highlight .gu {
227
+ color:#800080;
228
+ font-weight:bold
229
+ }
230
+
231
+
232
+ .highlight .kt {
233
+ color:#445588;
234
+ font-weight:bold
235
+ }
236
+
237
+ .highlight .m
238
+ , .highlight .mf
239
+ , .highlight .mh
240
+ , .highlight .mi
241
+ , .highlight .mo
242
+ , .highlight .il {
243
+ color:#009999
244
+ }
245
+
246
+ .highlight .s
247
+ , .highlight .sb
248
+ , .highlight .sc
249
+ , .highlight .sd
250
+ , .highlight .s2
251
+ , .highlight .se
252
+ , .highlight .sh
253
+ , .highlight .si
254
+ , .highlight .sx
255
+ , .highlight .s1 {
256
+ color:#d14
257
+ }
258
+
259
+ .highlight .n {
260
+ color:#333333
261
+ }
262
+
263
+ .highlight .na
264
+ , .highlight .no
265
+ , .highlight .nv
266
+ , .highlight .vc
267
+ , .highlight .vg
268
+ , .highlight .vi
269
+ , .highlight .nb {
270
+ color:#0086B3
271
+ }
272
+
273
+ .highlight .nc {
274
+ color:#445588;
275
+ font-weight:bold
276
+ }
277
+
278
+ .highlight .ni {
279
+ color:#800080
280
+ }
281
+
282
+ .highlight .ne
283
+ , .highlight .nf {
284
+ color:#990000;
285
+ font-weight:bold
286
+ }
287
+
288
+ .highlight .nt {
289
+ color:#000080
290
+ }
291
+
292
+ .highlight .ow {
293
+ font-weight:bold
294
+ }
295
+
296
+ .highlight .w {
297
+ color:#bbbbbb
298
+ }
299
+
300
+ .highlight .sr {
301
+ color:#009926
302
+ }
303
+
304
+ .highlight .ss {
305
+ color:#990073
306
+ }
307
+
308
+ .highlight .gc {
309
+ color:#999;
310
+ background-color:#EAF2F5
311
+ }
312
+
313
+ @media print {
314
+ .container {
315
+ background: transparent;
316
+ border-radius: 0;
317
+ padding: 0;
318
+ }
319
+
320
+ .body-content {
321
+ border: none;
322
+ }
323
+ }
324
+ </style>
325
+ </head>
326
+ <body>
327
+ <div class="container">
328
+ <div class="body-content"><h1 id="the-mit-license-mit-">The MIT License (MIT)</h1>
329
+ <p><strong>Copyright (c) 2016 Rod Vagg (the &quot;Original Author&quot;) and additional contributors</strong></p>
330
+ <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
331
+ <p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
332
+ <p>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
333
+ </div>
334
+ </div>
335
+ </body>
336
+ </html>
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # The MIT License (MIT)
2
+
3
+ **Copyright (c) 2016 Rod Vagg (the "Original Author") and additional contributors**
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,34 +1,16 @@
1
1
  # through2
2
2
 
3
- <!--
4
-
5
- soon ...
6
-
7
- [![Build Status](https://secure.travis-ci.org/rvagg/through2.png)](http://travis-ci.org/rvagg/through2)
8
-
9
- [![Build Status](https://saucelabs.com/browser-matrix/through2-sauce.svg)](https://travis-ci.org/rvagg/through2)
10
-
11
- -->
12
-
13
- [![NPM](https://nodei.co/npm/through2.png?compact=true)](https://nodei.co/npm/through2/)
14
-
15
- <!--
16
- not happy with these, we need to peg to readable-stream@1.0.x so it'll always report out-of-date
17
-
18
- [![david-dm](https://david-dm.org/rvagg/through2.png)](https://david-dm.org/rvagg/through2/)
19
- [![david-dm](https://david-dm.org/rvagg/through2/dev-status.png)](https://david-dm.org/rvagg/through2#info=devDependencies/)
20
- -->
3
+ [![NPM](https://nodei.co/npm/through2.png?downloads&downloadRank)](https://nodei.co/npm/through2/)
21
4
 
22
5
  **A tiny wrapper around Node streams.Transform (Streams2) to avoid explicit subclassing noise**
23
6
 
24
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) { ... })`.
25
8
 
26
- 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).
9
+ Note: As 2.x.x this module starts using **Streams3** instead of Stream2. To continue using a Streams2 version use `npm install through2@0` to fetch the latest version of 0.x.x. More information about Streams2 vs Streams3 and recommendations see the article **[Why I don't use Node's core 'stream' module](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html)**.
27
10
 
28
11
  ```js
29
12
  fs.createReadStream('ex.txt')
30
13
  .pipe(through2(function (chunk, enc, callback) {
31
-
32
14
  for (var i = 0; i < chunk.length; i++)
33
15
  if (chunk[i] == 97)
34
16
  chunk[i] = 122 // swap 'a' for 'z'
@@ -36,9 +18,11 @@ fs.createReadStream('ex.txt')
36
18
  this.push(chunk)
37
19
 
38
20
  callback()
39
-
40
21
  }))
41
22
  .pipe(fs.createWriteStream('out.txt'))
23
+ .on('finish', function () {
24
+ doSomethingSpecial()
25
+ })
42
26
  ```
43
27
 
44
28
  Or object streams:
@@ -49,17 +33,14 @@ var all = []
49
33
  fs.createReadStream('data.csv')
50
34
  .pipe(csv2())
51
35
  .pipe(through2.obj(function (chunk, enc, callback) {
52
-
53
36
  var data = {
54
37
  name : chunk[0]
55
38
  , address : chunk[3]
56
39
  , phone : chunk[10]
57
40
  }
58
-
59
41
  this.push(data)
60
42
 
61
43
  callback()
62
-
63
44
  }))
64
45
  .on('data', function (data) {
65
46
  all.push(data)
@@ -85,12 +66,12 @@ The `options` argument is first, unlike standard convention, because if I'm pass
85
66
 
86
67
  ```js
87
68
  fs.createReadStream('/tmp/important.dat')
88
- .pipe(through2({ objectMode: true, allowHalfOpen: false }, function (chunk, enc, cb) {
89
-
90
- this.push(new Buffer('wut?'))
91
- cb()
92
-
93
- })
69
+ .pipe(through2({ objectMode: true, allowHalfOpen: false },
70
+ function (chunk, enc, cb) {
71
+ cb(null, 'wut?') // note we can use the second argument on the callback
72
+ // to provide data as an alternative to this.push('wut?')
73
+ }
74
+ )
94
75
  .pipe(fs.createWriteStream('/tmp/wut.txt'))
95
76
  ```
96
77
 
@@ -108,13 +89,25 @@ If you **do not provide a `transformFunction`** then you will get a simple pass-
108
89
 
109
90
  The optional `flushFunction` is provided as the last argument (2nd or 3rd, depending on whether you've supplied options) is called just prior to the stream ending. Can be used to finish up any processing that may be in progress.
110
91
 
92
+ ```js
93
+ fs.createReadStream('/tmp/important.dat')
94
+ .pipe(through2(
95
+ function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop
96
+ function (cb) { // flush function
97
+ this.push('tacking on an extra buffer to the end');
98
+ cb();
99
+ }
100
+ ))
101
+ .pipe(fs.createWriteStream('/tmp/wut.txt'));
102
+ ```
103
+
111
104
  <b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b>
112
105
 
113
106
  Instead of returning a `stream.Transform` instance, `through2.ctor()` returns a **constructor** for a custom Transform. This is useful when you want to use the same transform logic in multiple instances.
114
107
 
115
108
  ```js
116
109
  var FToC = through2.ctor({objectMode: true}, function (record, encoding, callback) {
117
- if (record.temp != null && record.unit = "F") {
110
+ if (record.temp != null && record.unit == "F") {
118
111
  record.temp = ( ( record.temp - 32 ) * 5 ) / 9
119
112
  record.unit = "C"
120
113
  }
@@ -136,7 +129,8 @@ var converter = FToC({objectMode: true})
136
129
  - [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams.
137
130
  - [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams.
138
131
  - [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies.
132
+ - the [mississippi stream utility collection](https://github.com/maxogden/mississippi) includes `through2` as well as many more useful stream modules similar to this one
139
133
 
140
134
  ## License
141
135
 
142
- **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.
136
+ **through2** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) 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,10 +1,10 @@
1
1
  {
2
2
  "name": "through2",
3
- "version": "1.1.1",
3
+ "version": "2.0.3",
4
4
  "description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
5
5
  "main": "through2.js",
6
6
  "scripts": {
7
- "test": "node test/test.js",
7
+ "test": "node test/test.js | faucet",
8
8
  "test-local": "brtapsauce-local test/basic-test.js"
9
9
  },
10
10
  "repository": {
@@ -20,15 +20,13 @@
20
20
  "author": "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "readable-stream": ">=1.1.13-1 <1.2.0-0",
24
- "xtend": ">=4.0.0 <4.1.0-0"
23
+ "readable-stream": "^2.1.5",
24
+ "xtend": "~4.0.1"
25
25
  },
26
26
  "devDependencies": {
27
- "bl": ">=0.9.0 <0.10.0-0",
28
- "stream-spigot": ">=3.0.4 <3.1.0-0",
29
- "tape": ">=2.14.0 <2.15.0-0"
30
- },
31
- "publishConfig": {
32
- "tag": "1.0"
27
+ "bl": "~1.1.2",
28
+ "faucet": "0.0.1",
29
+ "stream-spigot": "~3.0.5",
30
+ "tape": "~4.6.2"
33
31
  }
34
32
  }
package/LICENSE DELETED
@@ -1,39 +0,0 @@
1
- Copyright 2013, Rod Vagg (the "Original Author")
2
- All rights reserved.
3
-
4
- MIT +no-false-attribs License
5
-
6
- Permission is hereby granted, free of charge, to any person
7
- obtaining a copy of this software and associated documentation
8
- files (the "Software"), to deal in the Software without
9
- restriction, including without limitation the rights to use,
10
- copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the
12
- Software is furnished to do so, subject to the following
13
- conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- Distributions of all or part of the Software intended to be used
19
- by the recipients as they would use the unmodified Software,
20
- containing modifications that substantially alter, remove, or
21
- disable functionality of the Software, outside of the documented
22
- configuration mechanisms provided by the Software, shall be
23
- modified such that the Original Author's bug reporting email
24
- addresses and urls are either replaced with the contact information
25
- of the parties responsible for the changes, or removed entirely.
26
-
27
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
29
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
31
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
32
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34
- OTHER DEALINGS IN THE SOFTWARE.
35
-
36
-
37
- Except where noted, this license applies to any and all software
38
- programs and associated documentation files created by the
39
- Original Author, when distributed with the Software.