raimohanska/bacon.js — pull request #49 by lauripiispanen (2013-01-24 08:42:09+00:00)
Title: Allow .fromEventTarget to define a custom mapping function

The motivation for this change stems from NodeJS EventEmitters allowing emission of multiple arguments to a callback. Currently bacon.js only emits the first of these callback arguments to the stream, and others are lost.

Example:
```
var ee = new (require('events').EventEmitter);

ee.on("event", function() { console.log(Array.prototype.slice.call(arguments)); });
ee.emit("event", "foo", "bar"); // [ 'foo', 'bar' ]

// whereas

Bacon.fromEventTarget(ee, "event").log();
ee.emit("event", "foo", "bar"); // 'foo'
```

With this change you can do:
```
Bacon.fromEventTarget(ee, "event", function() { return Array.prototype.slice.call(arguments); }).log();
ee.emit("event", "foo", "bar"); // ['foo', 'bar']
```