through2 0.6.5 → 1.0.0

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/.jshintrc ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "predef": [ ]
3
+ , "bitwise": false
4
+ , "camelcase": false
5
+ , "curly": false
6
+ , "eqeqeq": false
7
+ , "forin": false
8
+ , "immed": false
9
+ , "latedef": false
10
+ , "noarg": true
11
+ , "noempty": true
12
+ , "nonew": true
13
+ , "plusplus": false
14
+ , "quotmark": true
15
+ , "regexp": false
16
+ , "undef": true
17
+ , "unused": true
18
+ , "strict": false
19
+ , "trailing": true
20
+ , "maxlen": 120
21
+ , "asi": true
22
+ , "boss": true
23
+ , "debug": true
24
+ , "eqnull": true
25
+ , "esnext": true
26
+ , "evil": true
27
+ , "expr": true
28
+ , "funcscope": false
29
+ , "globalstrict": false
30
+ , "iterator": false
31
+ , "lastsemic": true
32
+ , "laxbreak": true
33
+ , "laxcomma": true
34
+ , "loopfunc": true
35
+ , "multistr": false
36
+ , "onecase": false
37
+ , "proto": false
38
+ , "regexdash": false
39
+ , "scripturl": true
40
+ , "smarttabs": false
41
+ , "shadow": false
42
+ , "sub": true
43
+ , "supernew": false
44
+ , "validthis": true
45
+ , "browser": true
46
+ , "couch": false
47
+ , "devel": false
48
+ , "dojo": false
49
+ , "mootools": false
50
+ , "node": true
51
+ , "nonstandard": true
52
+ , "prototypejs": false
53
+ , "rhino": false
54
+ , "worker": true
55
+ , "wsh": false
56
+ , "nomen": false
57
+ , "onevar": false
58
+ , "passfail": false
59
+ }
package/.npmignore CHANGED
@@ -1,3 +1 @@
1
- test
2
- .jshintrc
3
- .travis.yml
1
+ node_modules
package/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: node_js
2
+ node_js:
3
+ - '0.8'
4
+ - '0.10'
5
+ - '0.11'
6
+ branches:
7
+ only:
8
+ - master
9
+ notifications:
10
+ email:
11
+ - rod@vagg.org
12
+ script: npm test
13
+ env:
14
+ global:
15
+ - SAUCE_USER=through2-sauce
16
+ - secure: A8KyygIlklZOcTwTGhZHpkOu7Cn4tI1QQasg75CTSjudczGzkuh1pG2RDIkWqGcrWv9o5CjI6fFYYx0JvQu8o5PO+ZAtV1Z0AlnM965vE8kAx0XEC7giAV323bibfnHwyQu74vIhbOfdes7E4/cYerV2kAjK0T375D4DYEpDuvw=
17
+
package/README.md CHANGED
@@ -1,23 +1,40 @@
1
1
  # through2
2
2
 
3
- [![NPM](https://nodei.co/npm/through2.png?downloads&downloadRank)](https://nodei.co/npm/through2/)
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
+ -->
4
21
 
5
22
  **A tiny wrapper around Node streams.Transform (Streams2) to avoid explicit subclassing noise**
6
23
 
7
24
  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
25
 
9
- 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 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)**.
10
-
11
26
  ```js
12
27
  fs.createReadStream('ex.txt')
13
28
  .pipe(through2(function (chunk, enc, callback) {
29
+
14
30
  for (var i = 0; i < chunk.length; i++)
15
31
  if (chunk[i] == 97)
16
32
  chunk[i] = 122 // swap 'a' for 'z'
17
33
 
18
34
  this.push(chunk)
19
-
35
+
20
36
  callback()
37
+
21
38
  }))
22
39
  .pipe(fs.createWriteStream('out.txt'))
23
40
  ```
@@ -30,14 +47,17 @@ var all = []
30
47
  fs.createReadStream('data.csv')
31
48
  .pipe(csv2())
32
49
  .pipe(through2.obj(function (chunk, enc, callback) {
50
+
33
51
  var data = {
34
52
  name : chunk[0]
35
53
  , address : chunk[3]
36
54
  , phone : chunk[10]
37
55
  }
56
+
38
57
  this.push(data)
39
-
58
+
40
59
  callback()
60
+
41
61
  }))
42
62
  .on('data', function (data) {
43
63
  all.push(data)
@@ -63,12 +83,12 @@ The `options` argument is first, unlike standard convention, because if I'm pass
63
83
 
64
84
  ```js
65
85
  fs.createReadStream('/tmp/important.dat')
66
- .pipe(through2({ objectMode: true, allowHalfOpen: false },
67
- function (chunk, enc, cb) {
68
- cb(null, 'wut?') // note we can use the second argument on the callback
69
- // to provide data as an alternative to this.push('wut?')
70
- }
71
- )
86
+ .pipe(through2({ objectMode: true, allowHalfOpen: false }, function (chunk, enc, cb) {
87
+
88
+ this.push(new Buffer('wut?'))
89
+ cb()
90
+
91
+ })
72
92
  .pipe(fs.createWriteStream('/tmp/wut.txt'))
73
93
  ```
74
94
 
@@ -78,26 +98,12 @@ The `transformFunction` must have the following signature: `function (chunk, enc
78
98
 
79
99
  To queue a new chunk, call `this.push(chunk)`&mdash;this can be called as many times as required before the `callback()` if you have multiple pieces to send on.
80
100
 
81
- Alternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error.
82
-
83
- If you **do not provide a `transformFunction`** then you will get a simple pass-through stream.
101
+ If you **do not provide a `transformFunction`** then you will get a simple simple pass-through stream.
84
102
 
85
103
  ### flushFunction
86
104
 
87
105
  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.
88
106
 
89
- ```js
90
- fs.createReadStream('/tmp/important.dat')
91
- .pipe(through2(
92
- function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop
93
- function (cb) { // flush function
94
- this.push('tacking on an extra buffer to the end');
95
- cb();
96
- }
97
- ))
98
- .pipe(fs.createWriteStream('/tmp/wut.txt'));
99
- ```
100
-
101
107
  <b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b>
102
108
 
103
109
  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.
@@ -120,13 +126,6 @@ var converter = FToC()
120
126
  var converter = FToC({objectMode: true})
121
127
  ```
122
128
 
123
- ## See Also
124
-
125
- - [through2-map](https://github.com/brycebaril/through2-map) - Array.prototype.map analog for streams.
126
- - [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams.
127
- - [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams.
128
- - [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies.
129
-
130
129
  ## License
131
130
 
132
131
  **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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "through2",
3
- "version": "0.6.5",
3
+ "version": "1.0.0",
4
4
  "description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
5
5
  "main": "through2.js",
6
6
  "scripts": {
@@ -20,12 +20,16 @@
20
20
  "author": "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "readable-stream": ">=1.0.33-1 <1.1.0-0",
24
- "xtend": ">=4.0.0 <4.1.0-0"
23
+ "readable-stream": "~1.1.10",
24
+ "xtend": "~2.1.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"
27
+ "tape": "~2.3.0",
28
+ "bl": "~0.6.0",
29
+ "stream-spigot": "~3.0.1",
30
+ "brtapsauce": "~0.2.2"
31
+ },
32
+ "publishConfig": {
33
+ "tag": "1.0"
30
34
  }
31
35
  }
@@ -0,0 +1,334 @@
1
+ const test = require('tape')
2
+ , through2 = require('../')
3
+ , crypto = require('crypto')
4
+ , bl = require('bl')
5
+ , spigot = require('stream-spigot')
6
+
7
+ test('plain through', function (t) {
8
+ var th2 = through2(function (chunk, enc, callback) {
9
+ if (!this._i)
10
+ this._i = 97 // 'a'
11
+ else
12
+ this._i++
13
+ var b = new Buffer(chunk.length)
14
+ for (var i = 0; i < chunk.length; i++)
15
+ b[i] = this._i
16
+ this.push(b)
17
+ callback()
18
+ })
19
+
20
+ th2.pipe(bl(function (err, b) {
21
+ var s = b.toString('ascii')
22
+ t.equal('aaaaaaaaaabbbbbcccccccccc', s, 'got transformed string')
23
+ t.end()
24
+ }))
25
+
26
+ th2.write(crypto.randomBytes(10))
27
+ th2.write(crypto.randomBytes(5))
28
+ th2.write(crypto.randomBytes(10))
29
+ th2.end()
30
+ })
31
+
32
+ test('pipeable through', function (t) {
33
+ var th2 = through2(function (chunk, enc, callback) {
34
+ if (!this._i)
35
+ this._i = 97 // 'a'
36
+ else
37
+ this._i++
38
+ var b = new Buffer(chunk.length)
39
+ for (var i = 0; i < chunk.length; i++)
40
+ b[i] = this._i
41
+ this.push(b)
42
+ callback()
43
+ })
44
+
45
+ th2.pipe(bl(function (err, b) {
46
+ var s = b.toString('ascii')
47
+ // bl() acts like a proper streams2 stream and passes as much as it's
48
+ // asked for, so we really only get one write with such a small amount
49
+ // of data
50
+ t.equal(s, 'aaaaaaaaaaaaaaaaaaaaaaaaa', 'got transformed string')
51
+ t.end()
52
+ }))
53
+
54
+ var bufs = bl()
55
+ bufs.append(crypto.randomBytes(10))
56
+ bufs.append(crypto.randomBytes(5))
57
+ bufs.append(crypto.randomBytes(10))
58
+ bufs.pipe(th2)
59
+ })
60
+
61
+ test('object through', function (t) {
62
+ t.plan(3)
63
+
64
+ var th2 = through2({ objectMode: true}, function (chunk, enc, callback) {
65
+ this.push({ out: chunk.in + 1 })
66
+ callback()
67
+ })
68
+
69
+ var e = 0
70
+ th2.on('data', function (o) {
71
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
72
+ e++
73
+ })
74
+
75
+ th2.write({ in: 101 })
76
+ th2.write({ in: 202 })
77
+ th2.write({ in: -100 })
78
+ th2.end()
79
+ })
80
+
81
+ test('object through with through2.obj', function (t) {
82
+ t.plan(3)
83
+
84
+ var th2 = through2.obj(function (chunk, enc, callback) {
85
+ this.push({ out: chunk.in + 1 })
86
+ callback()
87
+ })
88
+
89
+ var e = 0
90
+ th2.on('data', function (o) {
91
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
92
+ e++
93
+ })
94
+
95
+ th2.write({ in: 101 })
96
+ th2.write({ in: 202 })
97
+ th2.write({ in: -100 })
98
+ th2.end()
99
+ })
100
+
101
+ test('flushing through', function (t) {
102
+ var th2 = through2(function (chunk, enc, callback) {
103
+ if (!this._i)
104
+ this._i = 97 // 'a'
105
+ else
106
+ this._i++
107
+ var b = new Buffer(chunk.length)
108
+ for (var i = 0; i < chunk.length; i++)
109
+ b[i] = this._i
110
+ this.push(b)
111
+ callback()
112
+ }, function (callback) {
113
+ this.push(new Buffer([ 101, 110, 100 ]))
114
+ callback()
115
+ })
116
+
117
+ th2.pipe(bl(function (err, b) {
118
+ var s = b.toString('ascii')
119
+ t.equal(s, 'aaaaaaaaaabbbbbccccccccccend', 'got transformed string')
120
+ t.end()
121
+ }))
122
+
123
+ th2.write(crypto.randomBytes(10))
124
+ th2.write(crypto.randomBytes(5))
125
+ th2.write(crypto.randomBytes(10))
126
+ th2.end()
127
+ })
128
+
129
+ test('plain through ctor', function (t) {
130
+ var Th2 = through2.ctor(function (chunk, enc, callback) {
131
+ if (!this._i)
132
+ this._i = 97 // 'a'
133
+ else
134
+ this._i++
135
+ var b = new Buffer(chunk.length)
136
+ for (var i = 0; i < chunk.length; i++)
137
+ b[i] = this._i
138
+ this.push(b)
139
+ callback()
140
+ })
141
+
142
+ var th2 = new Th2()
143
+
144
+ th2.pipe(bl(function (err, b) {
145
+ var s = b.toString('ascii')
146
+ t.equal('aaaaaaaaaabbbbbcccccccccc', s, 'got transformed string')
147
+ t.end()
148
+ }))
149
+
150
+ th2.write(crypto.randomBytes(10))
151
+ th2.write(crypto.randomBytes(5))
152
+ th2.write(crypto.randomBytes(10))
153
+ th2.end()
154
+ })
155
+
156
+ test('reuse through ctor', function (t) {
157
+ t.plan(4)
158
+
159
+ var Th2 = through2.ctor(function (chunk, enc, callback) {
160
+ if (!this._i) {
161
+ t.ok(1, 'did not contain previous instance data (this._i)')
162
+ this._i = 97 // 'a'
163
+ } else
164
+ this._i++
165
+ var b = new Buffer(chunk.length)
166
+ for (var i = 0; i < chunk.length; i++)
167
+ b[i] = this._i
168
+ this.push(b)
169
+ callback()
170
+ })
171
+
172
+ var th2 = Th2()
173
+
174
+ th2.pipe(bl(function (err, b) {
175
+ var s = b.toString('ascii')
176
+ t.equal('aaaaaaaaaabbbbbcccccccccc', s, 'got transformed string')
177
+
178
+ var newInstance = Th2()
179
+ newInstance.pipe(bl(function (err, b) {
180
+ var s = b.toString('ascii')
181
+ t.equal('aaaaaaabbbbccccccc', s, 'got transformed string')
182
+ }))
183
+
184
+ newInstance.write(crypto.randomBytes(7))
185
+ newInstance.write(crypto.randomBytes(4))
186
+ newInstance.write(crypto.randomBytes(7))
187
+ newInstance.end()
188
+ }))
189
+
190
+ th2.write(crypto.randomBytes(10))
191
+ th2.write(crypto.randomBytes(5))
192
+ th2.write(crypto.randomBytes(10))
193
+ th2.end()
194
+ })
195
+
196
+ test('object through ctor', function (t) {
197
+ t.plan(3)
198
+
199
+ var Th2 = through2.ctor({ objectMode: true}, function (chunk, enc, callback) {
200
+ this.push({ out: chunk.in + 1 })
201
+ callback()
202
+ })
203
+
204
+ var th2 = new Th2()
205
+
206
+ var e = 0
207
+ th2.on('data', function (o) {
208
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
209
+ e++
210
+ })
211
+
212
+ th2.write({ in: 101 })
213
+ th2.write({ in: 202 })
214
+ th2.write({ in: -100 })
215
+ th2.end()
216
+ })
217
+
218
+ test('pipeable object through ctor', function (t) {
219
+ t.plan(4)
220
+
221
+ var Th2 = through2.ctor({ objectMode: true}, function (record, enc, callback) {
222
+ if (record.temp != null && record.unit == 'F') {
223
+ record.temp = ( ( record.temp - 32 ) * 5 ) / 9
224
+ record.unit = 'C'
225
+ }
226
+ this.push(record)
227
+ callback()
228
+ })
229
+
230
+ var th2 = Th2()
231
+
232
+ var expect = [-19, -40, 100, 22]
233
+ th2.on('data', function (o) {
234
+ t.deepEqual(o, { temp: expect.shift(), unit: 'C' }, 'got transformed object')
235
+ })
236
+
237
+ spigot({objectMode: true}, [
238
+ {temp: -2.2, unit: 'F'},
239
+ {temp: -40, unit: 'F'},
240
+ {temp: 212, unit: 'F'},
241
+ {temp: 22, unit: 'C'}
242
+ ]).pipe(th2)
243
+ })
244
+
245
+ test('object through ctor override', function (t) {
246
+ t.plan(3)
247
+
248
+ var Th2 = through2.ctor(function (chunk, enc, callback) {
249
+ this.push({ out: chunk.in + 1 })
250
+ callback()
251
+ })
252
+
253
+ var th2 = Th2({objectMode: true})
254
+
255
+ var e = 0
256
+ th2.on('data', function (o) {
257
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
258
+ e++
259
+ })
260
+
261
+ th2.write({ in: 101 })
262
+ th2.write({ in: 202 })
263
+ th2.write({ in: -100 })
264
+ th2.end()
265
+ })
266
+
267
+ test('object settings available in transform', function (t) {
268
+ t.plan(6)
269
+
270
+ var Th2 = through2.ctor({objectMode: true, peek: true}, function (chunk, enc, callback) {
271
+ t.ok(this.options.peek, "reading options from inside _transform")
272
+ this.push({ out: chunk.in + 1 })
273
+ callback()
274
+ })
275
+
276
+ var th2 = Th2()
277
+
278
+ var e = 0
279
+ th2.on('data', function (o) {
280
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
281
+ e++
282
+ })
283
+
284
+ th2.write({ in: 101 })
285
+ th2.write({ in: 202 })
286
+ th2.write({ in: -100 })
287
+ th2.end()
288
+ })
289
+
290
+ test('object settings available in transform override', function (t) {
291
+ t.plan(6)
292
+
293
+ var Th2 = through2.ctor(function (chunk, enc, callback) {
294
+ t.ok(this.options.peek, "reading options from inside _transform")
295
+ this.push({ out: chunk.in + 1 })
296
+ callback()
297
+ })
298
+
299
+ var th2 = Th2({objectMode: true, peek: true})
300
+
301
+ var e = 0
302
+ th2.on('data', function (o) {
303
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
304
+ e++
305
+ })
306
+
307
+ th2.write({ in: 101 })
308
+ th2.write({ in: 202 })
309
+ th2.write({ in: -100 })
310
+ th2.end()
311
+ })
312
+
313
+ test('object override extends options', function (t) {
314
+ t.plan(6)
315
+
316
+ var Th2 = through2.ctor({objectMode: true}, function (chunk, enc, callback) {
317
+ t.ok(this.options.peek, "reading options from inside _transform")
318
+ this.push({ out: chunk.in + 1 })
319
+ callback()
320
+ })
321
+
322
+ var th2 = Th2({peek: true})
323
+
324
+ var e = 0
325
+ th2.on('data', function (o) {
326
+ t.deepEqual(o, { out: e === 0 ? 102 : e == 1 ? 203 : -99 }, 'got transformed object')
327
+ e++
328
+ })
329
+
330
+ th2.write({ in: 101 })
331
+ th2.write({ in: 202 })
332
+ th2.write({ in: -100 })
333
+ th2.end()
334
+ })
package/test/bench.js ADDED
@@ -0,0 +1,42 @@
1
+ /*
2
+ on rvagg@fletcher:
3
+ @0.2.3: Ran 36719 iterations in 10000 ms
4
+ */
5
+
6
+ const through2 = require('../')
7
+ , bl = require('bl')
8
+ , crypto = require('crypto')
9
+ , assert = require('assert')
10
+
11
+ function run (callback) {
12
+ var bufs = Array.apply(null, Array(10)).map(function () { return crypto.randomBytes(32) })
13
+ , stream = through2(function (chunk, env, callback) {
14
+ callback(null, chunk.toString('hex'))
15
+ })
16
+
17
+ stream.pipe(bl(function (err, data) {
18
+ assert(!err)
19
+ assert.equal(data.toString(), Buffer.concat(bufs).toString('hex'))
20
+ callback()
21
+ }))
22
+
23
+ bufs.forEach(function (b) {
24
+ stream.write(b)
25
+ })
26
+ stream.end()
27
+ }
28
+
29
+ var count = 0
30
+ , start = Date.now()
31
+
32
+ ;(function exec () {
33
+ count++
34
+ run(function () {
35
+ if (Date.now() - start < 1000 * 10) {
36
+ return setImmediate(exec)
37
+ }
38
+ console.log('Ran', count, 'iterations in', Date.now() - start, 'ms')
39
+ })
40
+ }())
41
+
42
+ console.log('Running for ~10s')
package/test/sauce.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ const user = process.env.SAUCE_USER
4
+ , key = process.env.SAUCE_KEY
5
+ , path = require('path')
6
+ , brtapsauce = require('brtapsauce')
7
+ , testFile = path.join(__dirname, 'basic-test.js')
8
+
9
+ , capabilities = [
10
+ { browserName: 'chrome' , platform: 'Windows XP', version: '' }
11
+ , { browserName: 'firefox' , platform: 'Windows 8' , version: '' }
12
+ , { browserName: 'firefox' , platform: 'Windows XP', version: '4' }
13
+ , { browserName: 'internet explorer' , platform: 'Windows 8' , version: '10' }
14
+ , { browserName: 'internet explorer' , platform: 'Windows 7' , version: '9' }
15
+ , { browserName: 'internet explorer' , platform: 'Windows 7' , version: '8' }
16
+ , { browserName: 'internet explorer' , platform: 'Windows XP', version: '7' }
17
+ , { browserName: 'internet explorer' , platform: 'Windows XP', version: '6' }
18
+ , { browserName: 'safari' , platform: 'Windows 7' , version: '5' }
19
+ , { browserName: 'safari' , platform: 'OS X 10.8' , version: '6' }
20
+ , { browserName: 'opera' , platform: 'Windows 7' , version: '' }
21
+ , { browserName: 'opera' , platform: 'Windows 7' , version: '11' }
22
+ , { browserName: 'ipad' , platform: 'OS X 10.8' , version: '6' }
23
+ , { browserName: 'android' , platform: 'Linux' , version: '4.0', 'device-type': 'tablet' }
24
+ ]
25
+
26
+ if (!user)
27
+ throw new Error('Must set a SAUCE_USER env var')
28
+ if (!key)
29
+ throw new Error('Must set a SAUCE_KEY env var')
30
+
31
+ brtapsauce({
32
+ name : 'Traversty'
33
+ , user : user
34
+ , key : key
35
+ , brsrc : testFile
36
+ , capabilities : capabilities
37
+ , options : { timeout: 60 * 6 }
38
+ })
package/test/test.js ADDED
@@ -0,0 +1,9 @@
1
+ require('./basic-test')
2
+
3
+ if (!process.env.SAUCE_KEY || !process.env.SAUCE_USER)
4
+ return console.log('SAUCE_KEY and/or SAUCE_USER not set, not running sauce tests')
5
+
6
+ if (!/v0\.10/.test(process.version))
7
+ return console.log('Not Node v0.10.x, not running sauce tests')
8
+
9
+ require('./sauce.js')
package/through2.js CHANGED
@@ -2,24 +2,6 @@ var Transform = require('readable-stream/transform')
2
2
  , inherits = require('util').inherits
3
3
  , xtend = require('xtend')
4
4
 
5
- function DestroyableTransform(opts) {
6
- Transform.call(this, opts)
7
- this._destroyed = false
8
- }
9
-
10
- inherits(DestroyableTransform, Transform)
11
-
12
- DestroyableTransform.prototype.destroy = function(err) {
13
- if (this._destroyed) return
14
- this._destroyed = true
15
-
16
- var self = this
17
- process.nextTick(function() {
18
- if (err)
19
- self.emit('error', err)
20
- self.emit('close')
21
- })
22
- }
23
5
 
24
6
  // a noop _transform function
25
7
  function noop (chunk, enc, callback) {
@@ -50,7 +32,7 @@ function through2 (construct) {
50
32
 
51
33
  // main export, just make me a transform stream!
52
34
  module.exports = through2(function (options, transform, flush) {
53
- var t2 = new DestroyableTransform(options)
35
+ var t2 = new Transform(options)
54
36
 
55
37
  t2._transform = transform
56
38
 
@@ -70,10 +52,10 @@ module.exports.ctor = through2(function (options, transform, flush) {
70
52
 
71
53
  this.options = xtend(options, override)
72
54
 
73
- DestroyableTransform.call(this, this.options)
55
+ Transform.call(this, this.options)
74
56
  }
75
57
 
76
- inherits(Through2, DestroyableTransform)
58
+ inherits(Through2, Transform)
77
59
 
78
60
  Through2.prototype._transform = transform
79
61
 
@@ -85,7 +67,7 @@ module.exports.ctor = through2(function (options, transform, flush) {
85
67
 
86
68
 
87
69
  module.exports.obj = through2(function (options, transform, flush) {
88
- var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
70
+ var t2 = new Transform(xtend({ objectMode: true }, options))
89
71
 
90
72
  t2._transform = transform
91
73