Filed here: https://github.com/joyent/node/issues/5256
Let me know if I should be more specific. On Monday, April 8, 2013 1:59:23 PM UTC-7, Isaac Schlueter wrote: > > Sure, that sounds like a good idea. Ideally, it'd auto-link to the > parent class in the html and json output. > > On Mon, Apr 8, 2013 at 11:26 AM, Liam <[email protected] <javascript:>> > wrote: > > Maybe the docs issue is that every place with "Class: module.Classname" > > should be immediately followed by "Inherits: mod1.ClassA, mod2.ClassB" > with > > hrefs to the relevant docs urls. > > > > Shall I file an issue to that effect? > > > > > > On Monday, April 8, 2013 10:36:31 AM UTC-7, Isaac Schlueter wrote: > >> > >> If only we could have prototypal inheritance for docs! > >> > >> On Mon, Apr 8, 2013 at 10:36 AM, Isaac Schlueter <[email protected]> wrote: > >> > If you create many objects of the same Writable type, it'll be > >> > significantly faster to subclass and use a constructor. If you only > >> > create one (or a very small number) it's equivalent performance-wise. > >> > > >> > I prefer to subclass if I'm going to add a lot of custom > >> > functionality, just because it's a bit cleaner in other code that > uses > >> > that class. For example, Socket objects inherit from Duplex, which > >> > inherits from Readable (prototypally) and Writable (parasitically). > >> > > >> > I'd accept a doc patch that mentions the error event, but it should > >> > probably just link back to the events.html page where it's explained. > >> > There's a lot of duplication in our documentation, but sadly, even > the > >> > duplication is not quite consistent, so you end up having holes like > >> > this. > >> > > >> > On Mon, Apr 8, 2013 at 12:15 AM, greelgorke <[email protected]> > wrote: > >> >> not really. you create the function once on module load, assignment > is > >> >> in a > >> >> creation: > >> >> > >> >> foo.js: > >> >> var Writable = require('stream').Writable > >> >> , _write = function(chunk, encoding, callback){ > >> >> // do something with chunk > >> >> // this ref points to a Writable instance > >> >> } > >> >> > >> >> module.exports = myCustomStream(){ > >> >> var s = new Writable() > >> >> s._wirte = _write > >> >> return s > >> >> } > >> >> > >> >> > >> >> it may be even more performant, because the _write function sits in > the > >> >> object itself not in it's prototype. A lookup up the prototype chain > is > >> >> less > >> >> performant, than a lookup of the 'own' property. > >> >> > >> >> but first you have to benchmark your specific case, before arguing > >> >> about > >> >> performance. > >> >> > >> >> Am Montag, 8. April 2013 04:07:59 UTC+2 schrieb Liam: > >> >>> > >> >>> Isn't there a cost of assigning a function to an object every time > you > >> >>> create such an object, vs. assigning to .prototype of a subclass? > >> >>> At the very least you're creating a closure around any variables in > >> >>> scope > >> >>> at the point of the assignment. > >> >>> > >> >>> > >> >>> On Sunday, April 7, 2013 1:27:50 PM UTC-7, greelgorke wrote: > >> >>>> > >> >>>> 2. both ways work. you could subclass or just create a Writabel > >> >>>> instance > >> >>>> and attach a new _write function. It's more a matter of style and > >> >>>> applied > >> >>>> paradigm. some prefer the mixin-approach, some inheritance. me > >> >>>> personally > >> >>>> prefer the mixin approach, because it's cleaner and more focused > on > >> >>>> actual > >> >>>> work, than pseudoclass-boilerplating. > >> >>>> > >> >>>> Am Sonntag, 7. April 2013 21:02:04 UTC+2 schrieb Liam: > >> >>>>> > >> >>>>> The v0.10 docs don't mention an 'error' event for > Stream.Writable. > >> >>>>> Is > >> >>>>> that a docs omission, or an API change? > >> >>>>> > >> >>>>> Stream.Writable#write() takes a callback that provides an error, > but > >> >>>>> the > >> >>>>> callback is described as 'optional'. If errors were only reported > >> >>>>> this way, > >> >>>>> surely it wouldn't be optional? > >> >>>>> > >> >>>>> Also, the docs don't give an example of defining a custom > >> >>>>> Stream.Writable. Should we define a subclass formally, or simply: > >> >>>>> > >> >>>>> var s = new Stream.Writable() > >> >>>>> s._write = function(...) {} // feels odd; I'm used to attaching > >> >>>>> functions to prototypes > >> >>>>> > >> >> -- > >> >> -- > >> >> 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.
