Created
August 27, 2014 09:37
-
-
Save risseraka/33293d21f858c2aecaf2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Readable = require('stream').Readable; | |
var readable = Readable(); | |
var read = false; | |
readable._read = function () { | |
console.log('reading'); | |
this.push(read ? null : '1'); | |
read = true; | |
}; | |
console.log('before on()'); | |
readable.pause(); | |
readable.on('data', function () { | |
console.log('got data in first listener'); | |
}); | |
readable.on('data', function () { | |
console.log('got data in second listener'); | |
throw new Error('something unexpected happened!'); | |
}); | |
readable.on('end', function () { | |
console.log('end of stream'); | |
}); | |
console.log('after on()'); | |
readable.resume(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment