Commit b0bdc8e5 by Konstantin Käfer

allow replacing particular parameters

parent 5c7de3da
......@@ -2,19 +2,20 @@
var EventEmitter = require('events').EventEmitter;
var util = require('util');
function extendTrace(object, property) {
function extendTrace(object, property, pos) {
var old = object[property];
object[property] = function(x) {
object[property] = function() {
var error = new Error();
var name = object.constructor.name + '#' + property + '(' +
Array.prototype.slice.call(arguments).map(function(el) {
return util.inspect(el, false, 0);
}).join(', ') + ')';
var last = arguments.length - 1;
var cb = arguments[last];
if (typeof arguments[last] === 'function') {
arguments[last] = function replacement() {
if (typeof pos === 'undefined') pos = -1;
if (pos < 0) pos += arguments.length;
var cb = arguments[pos];
if (typeof arguments[pos] === 'function') {
arguments[pos] = function replacement() {
try {
return cb.apply(this, arguments);
} 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