stream-collect
Advanced tools
Comparing version 1.1.0 to 1.2.0
12
index.js
@@ -109,5 +109,15 @@ /* jshint node: true */ | ||
function PassThrough(options) { | ||
if ( !(this instanceof PassThrough ) ) { | ||
return new PassThrough(options); | ||
} | ||
stream.PassThrough.call( this, options ); | ||
addToStream(this); | ||
this._resolved = null; | ||
this.on( 'pipe', function(source) { | ||
source.on( 'error', this.emit.bind( this, 'error' ) ); | ||
}.bind(this) ); | ||
} | ||
@@ -136,2 +146,2 @@ | ||
collect.addToStream = addToStream; | ||
collect.PassThrough = PassThrough; | ||
collect.PassThrough = collect.stream = PassThrough; |
{ | ||
"name": "stream-collect", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Collects the output of a stream as callback or promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -52,2 +52,4 @@ # Stream collect | ||
When piped, any errors from the source stream will be passed to this stream. | ||
```js | ||
@@ -54,0 +56,0 @@ |
@@ -17,2 +17,18 @@ /* jshint node: true, mocha: true */ | ||
it( 'creates a collect.PassThrough instance', function( ) { | ||
expect( new collect.PassThrough() ).toBeA( collect.PassThrough ); | ||
} ); | ||
it( 'is a PassThrough stream', function( ) { | ||
expect( new collect.PassThrough() ).toBeA( PassThrough ); | ||
} ); | ||
it( 'is can be instigated without new', function( ) { | ||
expect( collect.PassThrough() ).toBeA( PassThrough ); | ||
} ); | ||
it( 'collect.stream is a collect.PassThrough', function( ) { | ||
expect( collect.stream ).toBe( collect.PassThrough ); | ||
} ); | ||
it( 'collects buffer data', function(done) { | ||
@@ -201,19 +217,24 @@ var stream = new collect.PassThrough() | ||
it( 'passes errors from a piped stream', function() { | ||
var stream = new PassThrough(); | ||
var error = new Error('foo'); | ||
/*it( 'subsequent calls to then return the same data', function() { | ||
stream.write('foobar'); | ||
var stream = new collect.PassThrough(); | ||
stream.write(testDataPart1); | ||
stream.end(testDataPart2); | ||
return stream.then( function(data) { | ||
return stream.then(); | ||
var promise = stream | ||
.pipe( new collect.PassThrough() ) | ||
.then( function(data) { | ||
throw new Error( 'Should not have been called' ); | ||
} ) | ||
.catch( function(e) { | ||
expect(e).toBe(error); | ||
} ); | ||
stream.emit('error',error); | ||
return promise; | ||
} );*/ | ||
} ); | ||
} ); | ||
@@ -220,0 +241,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3305009
335
79