Is this the recommended way to read from a Readable stream in 0.10?

Suppose it's in the variable rs ...

rs.on('readable', function () {
  var chunk = rs.read();
  // do something with chunk
});

rs.on('end', function () {
  // move on
});

Can I assume that I will always get a 'readable" event when the stream is
ready to be read?

Can I assume I will get a new 'readable' event after every call to rs.read
unless the end of the stream was reached?

Is it better to do something like this inside the 'readable' callback to
continue calling read until it returns null?

  while (true) {
    var chunk = rs.read();
    if (!chunk) break;
    // do something with chunk
  }

-- 
R. Mark Volkmann
Object Computing, Inc.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to