Skip to content

Instantly share code, notes, and snippets.

@dannycoates
Created December 17, 2012 06:31
Show Gist options
  • Save dannycoates/4316203 to your computer and use it in GitHub Desktop.
Save dannycoates/4316203 to your computer and use it in GitHub Desktop.
Readable stream test
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