Skip to content

Commit

Permalink
Simplify EventEmitterEx.emit with ...args
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Jun 15, 2018
1 parent 58c36d3 commit ef29547
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/event_emitter_ex.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ function inspect(val) {

// add 'luster:eex' to the `NODE_DEBUG` environment variable to enable events logging
if (process.env.NODE_DEBUG && /luster:eex/i.test(process.env.NODE_DEBUG)) {
EventEmitterEx.prototype.emit = function() {
const args = Array.prototype
.slice.call(arguments, 0)
.map(inspect);
EventEmitterEx.prototype.emit = function(...args) {
const inspectedArgs = args.map(inspect).join(', ');

console.log('%s(%s).emit(%s)', this.constructor.name || 'EventEmitterEx', this.wid, args.join(', '));
console.log('%s(%s).emit(%s)', this.constructor.name || 'EventEmitterEx', this.wid, inspectedArgs);

return EventEmitter.prototype.emit.apply(this, arguments);
return EventEmitter.prototype.emit.apply(this, args);
};
}

Expand Down

0 comments on commit ef29547

Please sign in to comment.