Marco,

Easily monkeypatched/userlanded:

Stream.prototype.pipeErr = function(dest, opt) {
  var fw = dest.emit.bind(dest, 'error')
  this.on('error', fw)
  var self = this
  dest.on('unpipe', function (src) {
    if (src === self)
      dest.removeListener('error', fw)
  })
  return this.pipe(dest, opt)
}

Of course, that's not very flexible, since it only forwards errors,
not anything else.

In a general way, you can also do:

emitter.emit = otherEmitter.emit.bind(otherEmitter)

to steal ALL events.  (Not very helpful with streams, but there it is.)


If you want a shorter way to do it, I mean, there's also this kind of stuff:

src.on('error', dest.emit.bind(dest, 'error'))
  .pipe(dest)
  .on('blerg', src.emit.bind(src, 'destBlerg'))

If an options flag isn't terse enough for you, maybe you could sketch
what kind of API you're thinking of, or what problem you're actually
trying to solve.

> PS - I'm purposely not commenting on the example using domains. I don't have
> anything constructive to say.

This guy said it well:
https://twitter.com/afoolswisdom/status/273098921532878848

If you have something destructive to say about domains, go for it.
It's an experimental feature.  Destruction of incorrect features is
part of the construction of correct features.  We can't make it better
if you keep destructive comments to yourself :)

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

Reply via email to