Comparing version 0.2.9 to 0.2.10
(function() { | ||
var ERROR_ID, EventEmitter, create_callsite, current_trace_error, filename, format_location, format_method, in_prepare, limit_frames, prepareStackTrace, source_map, wrap_callback, __nextDomainTick, _addListener, _listeners, _nextTick, _on, _once, _ref, _setImmediate, _setInterval, _setTimeout; | ||
var ERROR_ID, EventEmitter, create_callsite, current_trace_error, filename, format_location, format_method, in_prepare, limit_frames, prepareStackTrace, source_map, util, wrap_callback, __nextDomainTick, _addListener, _listeners, _nextTick, _on, _ref, _setImmediate, _setInterval, _setTimeout; | ||
EventEmitter = require('events').EventEmitter; | ||
util = require('util'); | ||
if ((_ref = EventEmitter.prototype.on) != null ? _ref['longjohn'] : void 0) { | ||
@@ -205,4 +207,2 @@ return module.exports = EventEmitter.prototype.on['longjohn']; | ||
_once = EventEmitter.prototype.once; | ||
_listeners = EventEmitter.prototype.listeners; | ||
@@ -225,6 +225,20 @@ | ||
EventEmitter.prototype.once = function(event, callback) { | ||
var args; | ||
var args, fired, g, wrap; | ||
args = Array.prototype.slice.call(arguments); | ||
args[1] = wrap_callback(callback, 'EventEmitter.once'); | ||
return _once.apply(this, args); | ||
if (!util.isFunction(callback)) { | ||
throw TypeError('callback must be a function'); | ||
} | ||
fired = false; | ||
wrap = wrap_callback(callback, 'EventEmitter.once'); | ||
g = function() { | ||
this.removeListener(event, g); | ||
if (!fired) { | ||
fired = true; | ||
return wrap.apply(this, arguments); | ||
} | ||
}; | ||
g.listener = callback; | ||
args[1] = g; | ||
_on.apply(this, args); | ||
return this; | ||
}; | ||
@@ -231,0 +245,0 @@ |
{ | ||
"name": "longjohn", | ||
"description": "Long stack traces for node.js inspired by https://github.com/tlrobinson/long-stack-traces", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"homepage": "https://github.com/mattinsler/longjohn", | ||
@@ -6,0 +6,0 @@ "author": { |
13459
5
280