I think you should execute the code depending on the node-version. something like feature detection does not need here since we knows the changes from 0.6 to 0.8
On Thu, Jun 21, 2012 at 3:24 PM, Aleksey V Zapparov <i...@member.fsf.org>wrote: > On Thu, 21 Jun 2012 10:35:15 +0100 > Diogo Resende <drese...@thinkdigital.pt> wrote: > > > I have a module (node-rack) to abstract the cluster module. It was > > built for 0.6 and I want to be able to support 0.8 too but not > > dropping 0.6 support. I noticed for example that `kill()` was renamed > > to `destroy()`. I think this can be easy to detect but what about > > events? `death`event was changed to `exit`. > > you can subscribe to multiple events. > > > Is there a way to know what events an object supports or should I > > just check the node version (using process.version.node) and do my > > changes from there? > > > > I would prefer the first option as it's similar to feature detection. > > This way I would just check for available methods and events and use > > the preferred (and available) ones. > > Alternatively, yes you ca do it the way we are dealing with different > browsers: have a map of internal representation to actual one. In > general it can be represented as: > > ``` javascript > function get_node_ver() { > // some decisions and return as `06` for `0.6.x`, etc. > } > > var EVENTS = { > '06': { > exit: 'death', > // ... > }, > '08': { > exit: 'exit', > // ... > } > }; > > > EVENTS = EVENTS[get_node_ver()]; > ``` > > > -- > Sincerely yours, > Aleksey V. Zapparov A.K.A. ixti > FSF Member #7118 > Mobile Phone: +34 677 990 688 > Homepage: http://www.ixti.net > JID: zappa...@jabber.ru > > *Origin: Happy Hacking! > -- Arunoda Susiripala @arunoda <http://twitter.com/arunoda> <http://gplus.to/arunoda>https://github.com/arunoda http://www.linkedin.com/in/arunoda -- 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en