Skip to content

Instantly share code, notes, and snippets.

@mhart
Created July 3, 2013 05:42
Show Gist options
  • Save mhart/5915701 to your computer and use it in GitHub Desktop.
Save mhart/5915701 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
Trunc = require('truncating-stream'),
truncStream = new Trunc({limit: 10}),
readStream = fs.createReadStream('/dev/random')
readStream.on('end', function() { console.log('readStream ended') })
readStream.on('close', function() { console.log('readStream closed') })
readStream.pipe(truncStream).pipe(process.stdout)
setTimeout(function() { console.log('all done - did we close?') }, 10000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment