Dude, tell me about it! Even the streams in core were a total mess! Having a single place where most of the implementation lives is a huge win.
On Wed, Apr 3, 2013 at 11:06 AM, Jake Verbaten <[email protected]> wrote: >> 3. Make sure to not do anything even slightly wrong! > > This part is really hard. I don't think I've written a single stream module > that complies with it. (and I've written 60. it's really hard) > > > On Mon, Apr 1, 2013 at 5:39 PM, Isaac Schlueter <[email protected]> wrote: >> >> Compared with the stuff that you needed to do with streams1, streams2 >> is much much easier. Basically: >> >> 1. Pick the class you're extending: Readable, Writable, Duplex, Transform >> 2. Implement the constructor, and one method. (Well, 2 for Duplex, >> but that's to be expected.) >> >> If you are doing a non-byte string, then set `objectMode:true` in the >> appropriate options object. This is not something I personally >> recommend, but hey, some people like it. >> >> For 99% or more of use cases, this is all you need to do. >> >> Compare with streams1: >> >> 1. For readable streams, implement pause, resume, emit 'data' and >> 'end' events at the appropriate time. (Do you buffer while paused? >> Answers vary from "always" to "never".) >> 2. For writable streams, implement write() (which has to return the >> appropriate value if it buffers), and make sure to emit 'drain' if you >> ever return false, and implement end() (which can also can take a >> chunk argument). >> 3. Make sure to not do anything even slightly wrong! >> >> >> On Mon, Apr 1, 2013 at 10:45 AM, Mikeal Rogers <[email protected]> >> wrote: >> > 350 is a big number until you factor out the number of those written by >> > 3 >> > people (you, substack and Raynos). many modules might exists but, it is >> > my >> > impression, that most of them are written by about a dozen people. this >> > impression could be wrong but i've been around since we first started >> > defining this API and every time i sit down to write a new stream i get >> > bit >> > by something i forgot i needed to do. >> > >> > -Mikeal >> > >> > On Apr 1, 2013, at 10:41AM, Dominic Tarr <[email protected]> wrote: >> > >> > @mikeal when I last checked a few weeks ago there where over 350 stream >> > modules in npm. >> > >> > >> > >> > >> > On Tue, Mar 26, 2013 at 9:38 PM, Isaac Schlueter <[email protected]> wrote: >> >> >> >> > You're still doing it wrong. This is like complaining that you can't >> >> > tell a stream is ended because you waited to attach an `end` event >> >> > handler. >> >> >> >> But that's supported, now :) If you don't consume the stream, it >> >> never emits 'end', even if it never has any data. You still have to >> >> read() or on('data') or resume() it. >> >> >> >> You could argue that the 'readable' is only for state transitions, I >> >> suppose, and the correct approach is to try to read, and only wait for >> >> 'readable' if there's nothing there. But there's little harm in >> >> re-emitting the event, at least the first time, and it's an easy >> >> change to make. (We already special-case 'data' and 'readable' for >> >> other reasons.) >> >> >> >> Part of the reason why this is an issue for you is that the HTTP >> >> implementation's interaction with the TCP layer is utter shit. Look >> >> for changes there in 0.12. In the meantime, we should make this work, >> >> if only because some other crappily-built stream is likely to be >> >> similarly broken in this surprising way ;) >> >> >> >> Taking the bug report to an issue is 100% the correct move, thanks. >> >> Let's continue the discussion of that specific point there. >> >> >> >> -- >> >> -- >> >> 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. >> >> >> >> >> > >> > >> > -- >> > -- >> > 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. >> > >> > >> > >> > >> > -- >> > -- >> > 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. >> > >> > >> >> -- >> -- >> 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. >> >> > > -- > -- > 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. > > -- -- 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.
