~ubuntu-branches/ubuntu/trusty/nodejs/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/events.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-12-12 23:04:07 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20131212230407-xfa6gka4c6oatsx1
Tags: 0.10.23~dfsg1-1
* Upstream update.
* Refresh patches, remove 1005 patch, applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
// that to be increased. Set to zero for unlimited.
46
46
var defaultMaxListeners = 10;
47
47
EventEmitter.prototype.setMaxListeners = function(n) {
48
 
  if (typeof n !== 'number' || n < 0)
 
48
  if (typeof n !== 'number' || n < 0 || isNaN(n))
49
49
    throw TypeError('n must be a positive number');
50
50
  this._maxListeners = n;
51
51
};
170
170
  if (typeof listener !== 'function')
171
171
    throw TypeError('listener must be a function');
172
172
 
 
173
  var fired = false;
 
174
 
173
175
  function g() {
174
176
    this.removeListener(type, g);
175
 
    listener.apply(this, arguments);
 
177
 
 
178
    if (!fired) {
 
179
      fired = true;
 
180
      listener.apply(this, arguments);
 
181
    }
176
182
  }
177
183
 
178
184
  g.listener = listener;
257
263
 
258
264
  if (typeof listeners === 'function') {
259
265
    this.removeListener(type, listeners);
260
 
  } else {
 
266
  } else if (Array.isArray(listeners)) {
261
267
    // LIFO order
262
268
    while (listeners.length)
263
269
      this.removeListener(type, listeners[listeners.length - 1]);