FAQ
Hi,

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`.

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.

--
Diogo Resende

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

  • Aleksey V Zapparov at Jun 21, 2012 at 9:54 am

    On Thu, 21 Jun 2012 10:35:15 +0100 Diogo Resende 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: zapparov@jabber.ru

    *Origin: Happy Hacking!
  • Arunoda Susiripala at Jun 21, 2012 at 9:57 am
    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 wrote:

    On Thu, 21 Jun 2012 10:35:15 +0100
    Diogo Resende 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: zapparov@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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Diogo Resende at Jun 21, 2012 at 11:36 am
    I understand your point, but imagine that in 1.0 or 0.10 the event name comes back to what it was in 0.6. If I had a something like EventModule.hasEvent("x") I didn't need to do this. Of course to do this, the modules had to register the event.

    This only applies to events, methods are pretty easy to detect. This is just an idea of an "upgrade" to the EventEmitter.

    Well.. I'll have to base the code on node version...

    --
    Diogo Resende

    On Thursday, June 21, 2012 at 10:57 , Arunoda Susiripala wrote:

    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 (mailto:ixti@member.fsf.org)> wrote:
    On Thu, 21 Jun 2012 10:35:15 +0100
    Diogo Resende (mailto:dresende@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 (tel:%2B34%20677%20990%20688)
    Homepage: http://www.ixti.net
    JID: zapparov@jabber.ru (mailto:zapparov@jabber.ru)

    *Origin: Happy Hacking!


    --
    Arunoda Susiripala

    @arunoda (http://twitter.com/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 (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Javier Arevalo at Jun 23, 2012 at 11:52 pm
    Feature detection is intended for known features but unknown combinations
    of them. For example, in that hypothetical 1.0, you can only detect that
    the event name is back, not that it means the same as it did in 0.6.

    On Thursday, June 21, 2012 1:36:01 PM UTC+2, Diogo Resende wrote:

    I understand your point, but imagine that in 1.0 or 0.10 the event name
    comes back to what it was in 0.6. If I had a something like
    EventModule.hasEvent("x") I didn't need to do this. Of course to do this,
    the modules had to register the event.

    This only applies to events, methods are pretty easy to detect. This is
    just an idea of an "upgrade" to the EventEmitter.

    Well.. I'll have to base the code on node version...

    --
    Diogo Resende

    On Thursday, June 21, 2012 at 10:57 , Arunoda Susiripala wrote:

    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 wrote:

    On Thu, 21 Jun 2012 10:35:15 +0100
    Diogo Resende 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: zapparov@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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Diogo Resende at Jun 24, 2012 at 10:20 pm

    On Sunday, June 24, 2012 at 0:52 , Javier Arevalo wrote:
    Feature detection is intended for known features but unknown combinations of them. For example, in that hypothetical 1.0, you can only detect that the event name is back, not that it means the same as it did in 0.6.
    It would be kind of freaky go resurrect an event with the same name and different meaning/context. I understand it is good to politely enforce people to use recent versions of node, but sometimes that is not possible. One cannot just update node in a production server because of a module and risk something in other things.

    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Roly Fentanes at Jun 21, 2012 at 12:14 pm
    I'm in a similar situation with a module I wrote. And I think I'll just
    write a note in the readme specifying which version should be installed for
    node v0.6.x.
    On Thursday, June 21, 2012 2:35:15 AM UTC-7, Diogo Resende wrote:

    Hi,

    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`.

    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.

    --
    Diogo Resende
    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Dominic Tarr at Jun 22, 2012 at 1:38 am
    you can set what version of node a module is for in the package.json

    "engines": { "node" : "0.6" }

    for example. this does mean you'll have two versions of the code,
    feature detection may be easier to maintain. you choice.

    see `npm help json`

    On Fri, Jun 22, 2012 at 12:14 AM, Roly Fentanes wrote:
    I'm in a similar situation with a module I wrote. And I think I'll just
    write a note in the readme specifying which version should be installed for
    node v0.6.x.

    On Thursday, June 21, 2012 2:35:15 AM UTC-7, Diogo Resende wrote:

    Hi,

    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`.

    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.

    --
    Diogo Resende
    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Diogo Resende at Jun 22, 2012 at 11:19 am
    The goal is to have a module compatible with both 0.6 and 0.8, not one for each version.

    --
    Diogo Resende

    On Friday, June 22, 2012 at 2:37 , Dominic Tarr wrote:

    you can set what version of node a module is for in the package.json

    "engines": { "node" : "0.6" }

    for example. this does mean you'll have two versions of the code,
    feature detection may be easier to maintain. you choice.

    see `npm help json`

    On Fri, Jun 22, 2012 at 12:14 AM, Roly Fentanes (mailto:roly426@gmail.com)> wrote:
    I'm in a similar situation with a module I wrote. And I think I'll just
    write a note in the readme specifying which version should be installed for
    node v0.6.x.

    On Thursday, June 21, 2012 2:35:15 AM UTC-7, Diogo Resende wrote:

    Hi,

    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`.

    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.

    --
    Diogo Resende
    --
    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 (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    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 (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Tim Dickinson at Jun 23, 2012 at 8:09 pm

    The goal is to have a module compatible with both 0.6 and 0.8, not one
    for each version.
    At some point you will have to. No one writes code for version 0.4, the
    same should now be true for version 0.6. You should encourage the uses of
    new build's of node. The cluster module was brand new in 0.6 and from what
    I understand the api is frozen for 0.8 to account for stability.

    Just pulling this from a gist.
    The v0.6 release family will continue to see releases for critical
    bugfixes and security issues through the end of 2012. However, it will not
    be the main focus of the core team's attention.

    --
    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+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedJun 21, '12 at 9:35a
activeJun 24, '12 at 10:20p
posts10
users7
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase