lib/orderQueue.js
function (id, objId, object, clb, fn) {
    this.queue[id] = this.queue[id] || [];

    var alreadyInQueue = _.find(this.queue[id], function (o) {
      return o.id === objId;
    });

    if (alreadyInQueue) {
      debug('event already handling [concatenatedId]=' + id + ', [evtId]=' + objId);
      clb(new AlreadyHandlingError('Event: [id]=' + objId + ', [evtId]=' + objId + ' already handling!'), function (done) {
        done(null);
      });
      return;
    }

    this.queue[id].push({ id: objId, payload: object, callback: clb });

    this.retries[id] = this.retries[id] || {};

    this.retries[id][objId] = this.retries[id][objId] || 0;

    if (fn) {
      var self = this;
      (function wait () {
        debug('wait called [concatenatedId]=' + id + ', [evtId]=' + objId);
        setTimeout(function () {
          var found = _.find(self.queue[id], function (o) {
            return o.id === objId;
          });
          if (found) {
            var loopCount = self.retries[id][objId]++;
            fn(loopCount, wait);
          }
        }, self.options.queueTimeout);
      })();
    }
  }
function (id, objId, object, clb, fn) {
    this.queue[id] = this.queue[id] || [];

    var alreadyInQueue = _.find(this.queue[id], function (o) {
      return o.id === objId;
    });

    if (alreadyInQueue) {
      debug('event already handling [concatenatedId]=' + id + ', [evtId]=' + objId);
      clb(new AlreadyHandlingError('Event: [id]=' + objId + ', [evtId]=' + objId + ' already handling!'), function (done) {
        done(null);
      });
      return;
    }

    this.queue[id].push({ id: objId, payload: object, callback: clb });

    this.retries[id] = this.retries[id] || {};

    this.retries[id][objId] = this.retries[id][objId] || 0;

    if (fn) {
      var self = this;
      (function wait () {
        debug('wait called [concatenatedId]=' + id + ', [evtId]=' + objId);
        setTimeout(function () {
          var found = _.find(self.queue[id], function (o) {
            return o.id === objId;
          });
          if (found) {
            var loopCount = self.retries[id][objId]++;
            fn(loopCount, wait);
          }
        }, self.options.queueTimeout);
      })();
    }
  }
function ( id , objId , object , clb , fn ) { this . queue [ id ] = this . queue [ id ] || [ ] ; var alreadyInQueue = _ . find ( this . queue [ id ] , function ( o ) { return o . id === objId ; } ) ; if ( alreadyInQueue ) { debug ( 'event already handling [concatenatedId]=' + id + ', [evtId]=' + objId ) ; clb ( new AlreadyHandlingError ( 'Event: [id]=' + objId + ', [evtId]=' + objId + ' already handling!' ) , function ( done ) { done ( null ) ; } ) ; return ; } this . queue [ id ] . push ( { id : objId , payload : object , callback : clb } ) ; this . retries [ id ] = this . retries [ id ] || { } ; this . retries [ id ] [ objId ] = this . retries [ id ] [ objId ] || 0 ; if ( fn ) { var self = this ; ( function wait ( ) { debug ( 'wait called [concatenatedId]=' + id + ', [evtId]=' + objId ) ; setTimeout ( function ( ) { var found = _ . find ( self . queue [ id ] , function ( o ) { return o . id === objId ; } ) ; if ( found ) { var loopCount = self . retries [ id ] [ objId ] ++ ; fn ( loopCount , wait ) ; } } , self . options . queueTimeout ) ; } ) ( ) ; } }
Pushes a new item in the queue.
@param {String}   id     The aggregate id.
@param {String}   objId  The event id.
@param {Object}   object The event.
@param {Function} clb    The callback function for the event handle.
@param {Function} fn     The timeout function handle.
Pushes a new item in the queue .