lib/wrapper.js
function wrapArguments(trace, clientState, hooks) {
  //wrap any callbacks found in the arguments
  var args = trace.args;
  var handler = clientState.rules.handleArgs(trace.funInfo.name);
  if (handler) {
    handler(trace, clientState);
  }
  for (var i = args.length - 1; i >= 0; i--) {
    var a = args[i];
    if (util.isFunction(a) && !a.__concurix_blacklisted) {
      var callbackState = {
        modInfo: clientState.modInfo,
        rules: clientState.rules,
        callbackOf: trace
      };

      if (wrap.isWrapper(args[i])) {
        args[i].__concurix_proxy_state__
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      else {
        args[i] = wrap(a)
          .before(hooks.beforeHook)
          .after(hooks.afterHook)
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      trace.origFunctionArguments = trace.origFunctionArguments || [];
      trace.origFunctionArguments.push(a);
    }
  }
}
function wrapArguments(trace, clientState, hooks) {
  //wrap any callbacks found in the arguments
  var args = trace.args;
  var handler = clientState.rules.handleArgs(trace.funInfo.name);
  if (handler) {
    handler(trace, clientState);
  }
  for (var i = args.length - 1; i >= 0; i--) {
    var a = args[i];
    if (util.isFunction(a) && !a.__concurix_blacklisted) {
      var callbackState = {
        modInfo: clientState.modInfo,
        rules: clientState.rules,
        callbackOf: trace
      };

      if (wrap.isWrapper(args[i])) {
        args[i].__concurix_proxy_state__
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      else {
        args[i] = wrap(a)
          .before(hooks.beforeHook)
          .after(hooks.afterHook)
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      trace.origFunctionArguments = trace.origFunctionArguments || [];
      trace.origFunctionArguments.push(a);
    }
  }
}
function wrapArguments ( trace , clientState , hooks ) { //wrap any callbacks found in the arguments var args = trace . args ; var handler = clientState . rules . handleArgs ( trace . funInfo . name ) ; if ( handler ) { handler ( trace , clientState ) ; } for ( var i = args . length - 1 ; i >= 0 ; i -- ) { var a = args [ i ] ; if ( util . isFunction ( a ) && ! a . __concurix_blacklisted ) { var callbackState = { modInfo : clientState . modInfo , rules : clientState . rules , callbackOf : trace } ; if ( wrap . isWrapper ( args [ i ] ) ) { args [ i ] . __concurix_proxy_state__ . module ( ( trace . calledBy && trace . calledBy . moduleName ) || 'root' ) . state ( callbackState ) . nameIfNeeded ( trace . funInfo . name + ' callback' ) . getProxy ( ) ; } else { args [ i ] = wrap ( a ) . before ( hooks . beforeHook ) . after ( hooks . afterHook ) . module ( ( trace . calledBy && trace . calledBy . moduleName ) || 'root' ) . state ( callbackState ) . nameIfNeeded ( trace . funInfo . name + ' callback' ) . getProxy ( ) ; } trace . origFunctionArguments = trace . origFunctionArguments || [ ] ; trace . origFunctionArguments . push ( a ) ; } } }
iterate through arguments and wrap functions as callbacks
iterate through arguments and wrap functions as callbacks