I see that zlib streams accept a callback to their write method, which will be called when the input buffer is completely read (I'm guessing). But I don't see documentation of that in the API docs. Is it safe to use this feature?
On Tue, Oct 9, 2012 at 12:42 PM, khs4473 <khs4...@gmail.com> wrote:
> I see that zlib streams accept a callback to their write method, which will
> be called when the input buffer is completely read (I'm guessing). But I
> don't see documentation of that in the API docs. Is it safe to use this
If you add a listener on the 'data' event, or call .pause() or
.resume(), then new style streams will switch into old-style. So,
existing programs should Just Work, but there are a bunch of new
classes that you'll be able to use to extend in userland streams so
that they play nicely with everything else.
I could be misguided, but I find that I gravitate toward low-level IO, like the interface that fs provides. The cool thing about fs (not the streams, but the posix functions), is that I can wrap them in whatever abstraction makes sense at the time. I can create my own stream classes around it, or I can make it callback-based or promise-based if I prefer. At the lowest level, it's pure simplicity:
read: fill this buffer with this many bytes, please, and call this function when yer done (and let me know how much you wrote).
write: write this many bytes from this buffer and let me know when you're done with said buffer.