@ -40,8 +40,6 @@ function Parser(stream, debug) {
this . _ignoreReadable = false ;
this . _ignoreReadable = false ;
this . debug = debug ;
this . debug = debug ;
this . setStream ( stream ) ;
var self = this ;
var self = this ;
this . _cbReadable = function ( ) {
this . _cbReadable = function ( ) {
if ( self . _ignoreReadable )
if ( self . _ignoreReadable )
@ -51,12 +49,18 @@ function Parser(stream, debug) {
else
else
self . _tryread ( ) ;
self . _tryread ( ) ;
} ;
} ;
this . _stream . on ( 'readable' , this . _cbReadable ) ;
this . setStream ( stream ) ;
process . nextTick ( this . _cbReadable ) ;
process . nextTick ( this . _cbReadable ) ;
}
}
inherits ( Parser , EventEmitter ) ;
inherits ( Parser , EventEmitter ) ;
Parser . prototype . setStream = function ( stream ) {
Parser . prototype . setStream = function ( stream ) {
if ( this . _stream ) {
this . _stream . removeListener ( 'readable' , this . _cbReadable ) ;
}
if ( /^v0\.8\./ . test ( process . version ) ) {
if ( /^v0\.8\./ . test ( process . version ) ) {
this . _stream = ( new ReadableStream ( ) ) . wrap ( stream ) ;
this . _stream = ( new ReadableStream ( ) ) . wrap ( stream ) ;
@ -66,6 +70,8 @@ Parser.prototype.setStream = function(stream) {
stream . _events . error . pop ( ) ;
stream . _events . error . pop ( ) ;
} else
} else
this . _stream = stream ;
this . _stream = stream ;
this . _stream . on ( 'readable' , this . _cbReadable ) ;
} ;
} ;
Parser . prototype . _tryread = function ( n ) {
Parser . prototype . _tryread = function ( n ) {