Created
December 17, 2012 06:31
-
-
Save dannycoates/4316203 to your computer and use it in GitHub Desktop.
Readable stream test
This file contains 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 fs = require('fs') | |
var Readable = require('readable-stream') | |
var readable = new Readable({ bufferSize: 64 }) | |
readable.wrap(fs.createReadStream(__filename)) | |
readable.on( | |
'readable', | |
function () { | |
var data = '' | |
while(data !== null) { | |
process.stdout.write(data) | |
data = readable.read(10) | |
} | |
} | |
) | |
// this script should print itself in its entirety |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment