Commit b0bdc8e5 by Konstantin Käfer

allow replacing particular parameters

parent 5c7de3da
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;
var util = require('util'); var util = require('util');
function extendTrace(object, property) { function extendTrace(object, property, pos) {
var old = object[property]; var old = object[property];
object[property] = function(x) { object[property] = function() {
var error = new Error(); var error = new Error();
var name = object.constructor.name + '#' + property + '(' + var name = object.constructor.name + '#' + property + '(' +
Array.prototype.slice.call(arguments).map(function(el) { Array.prototype.slice.call(arguments).map(function(el) {
return util.inspect(el, false, 0); return util.inspect(el, false, 0);
}).join(', ') + ')'; }).join(', ') + ')';
var last = arguments.length - 1; if (typeof pos === 'undefined') pos = -1;
var cb = arguments[last]; if (pos < 0) pos += arguments.length;
if (typeof arguments[last] === 'function') { var cb = arguments[pos];
arguments[last] = function replacement() { if (typeof arguments[pos] === 'function') {
arguments[pos] = function replacement() {
try { try {
return cb.apply(this, arguments); return cb.apply(this, arguments);
} catch (err) { } catch (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment