As an update to this (I realise nodeconf has been on... pity I missed it),
I've tried a few things and I still can't figure out the idiomatic way to
deal with this situation. Here's an example:
var stream = require('stream'),
fs = require('fs')
var readStream = fs.createReadStream(__filenam
Spend a lot of time trying to solve similar issue (terminate nod needed
anymore reading stream in case of app error), seems like there's no
`destroy` method in Stream's Documentation, would be nice to have it there.
Or is it deprecated?
On Friday, June 28, 2013 11:01:46 AM UTC+4, Michael Hart wr
Here's one way to do it: https://github.com/isaacs/truncating-stream
npm install truncating-stream
var Trunc = require('truncating-stream')
var t = new Trunc({ limit: 100 })
Now no matter how much you t.write() only 100 bytes will come out.
Of course, the thing you're piping your reader INTO wo
Ah, so I might not have been clear enough with the way I phrased it - I
didn't actually want to know how to write the *truncating* stream (although
thank you!) - I wanted to know how to write the *read* stream.
If I'm writing a module that exposes a read stream that is reading from a
database -
In a convo with @isaacs on Twitter, the example of EPIPE in Unix pipes was
brought up - if I understand correctly, this is exactly the mechanism I'm
looking for in node.js streams.
So when you do `cat myfile | grep 'hello' | head -5` - EPIPE will be thrown
if there are more than 5 matches and `