lib/middleware.js
function run(events, payload, callback)
{
  // if no callback supplied assume it's two arguments call
  if (!callback)
  {
    callback = payload;
    payload  = events;
    events   = null;
  }

  // make it uniform
  events = normalizeEvents(events);

  // apply events/middleware asynchronously and sequentially
  pipeline(events, payload, function(e, data, cb)
  {
    if (!Array.isArray(this._stack[e]))
    {
      this.logger.debug({message: 'Reached end of the stack', event: e, data: data});
      cb(null, payload);
      return;
    }

    pipeline(this._stack[e], data, tryCall, cb);
  }.bind(this), callback);
}
function run(events, payload, callback)
{
  // if no callback supplied assume it's two arguments call
  if (!callback)
  {
    callback = payload;
    payload  = events;
    events   = null;
  }

  // make it uniform
  events = normalizeEvents(events);

  // apply events/middleware asynchronously and sequentially
  pipeline(events, payload, function(e, data, cb)
  {
    if (!Array.isArray(this._stack[e]))
    {
      this.logger.debug({message: 'Reached end of the stack', event: e, data: data});
      cb(null, payload);
      return;
    }

    pipeline(this._stack[e], data, tryCall, cb);
  }.bind(this), callback);
}
function run ( events , payload , callback ) { // if no callback supplied assume it's two arguments call if ( ! callback ) { callback = payload ; payload = events ; events = null ; } // make it uniform events = normalizeEvents ( events ) ; // apply events/middleware asynchronously and sequentially pipeline ( events , payload , function ( e , data , cb ) { if ( ! Array . isArray ( this . _stack [ e ] ) ) { this . logger . debug ( { message : 'Reached end of the stack' , event : e , data : data } ) ; cb ( null , payload ) ; return ; } pipeline ( this . _stack [ e ] , data , tryCall , cb ) ; } . bind ( this ) , callback ) ; }
Runs middleware in the stack for the provided events with passed payload

@this  Fbbot#
@param {string|array} [events] - list of events to determine middleware set to iterate over
@param {object} payload - event payload to pass along to middleware
@param {function} callback - invoked after (if) all middleware been processed
Runs middleware in the stack for the provided events with passed payload