services/inter_comm/base.js
async function (events) {
    const oThis = this
      , promiseArray = []
    ;

    // nothing to do
    if (!events || events.length === 0) {
      oThis.updateIntercomDataFile();
      return Promise.resolve();
    }

    //TODO: last processed transaction index.
    for (var i = 0; i < events.length; i++) {
      const eventObj = events[i]
        , j = i
      ;

      // await oThis.processEventObj(eventObj);

      if (oThis.parallelProcessingAllowed()) {
        promiseArray.push(new Promise(function (onResolve, onReject) {
          setTimeout(function () {
            oThis.processEventObj(eventObj)
              .then(onResolve)
              .catch(function (error) {
                logger.error('##### inside catch block #####: ', error);
                return onResolve();
              });
          }, (j * 1000 + 100));
        }));
      } else {
        await oThis.processEventObj(eventObj)
          .catch(function (error) {
            logger.error('inside catch block: ', error);
            return Promise.resolve();
          });
      }
    }

    if (oThis.parallelProcessingAllowed()) {
      await Promise.all(promiseArray);
    }

    oThis.updateIntercomDataFile();
    return Promise.resolve();
  }
async function (events) {
    const oThis = this
      , promiseArray = []
    ;

    // nothing to do
    if (!events || events.length === 0) {
      oThis.updateIntercomDataFile();
      return Promise.resolve();
    }

    //TODO: last processed transaction index.
    for (var i = 0; i < events.length; i++) {
      const eventObj = events[i]
        , j = i
      ;

      // await oThis.processEventObj(eventObj);

      if (oThis.parallelProcessingAllowed()) {
        promiseArray.push(new Promise(function (onResolve, onReject) {
          setTimeout(function () {
            oThis.processEventObj(eventObj)
              .then(onResolve)
              .catch(function (error) {
                logger.error('##### inside catch block #####: ', error);
                return onResolve();
              });
          }, (j * 1000 + 100));
        }));
      } else {
        await oThis.processEventObj(eventObj)
          .catch(function (error) {
            logger.error('inside catch block: ', error);
            return Promise.resolve();
          });
      }
    }

    if (oThis.parallelProcessingAllowed()) {
      await Promise.all(promiseArray);
    }

    oThis.updateIntercomDataFile();
    return Promise.resolve();
  }
async function ( events ) { const oThis = this , promiseArray = [ ] ; // nothing to do if ( ! events || events . length === 0 ) { oThis . updateIntercomDataFile ( ) ; return Promise . resolve ( ) ; } //TODO: last processed transaction index. for ( var i = 0 ; i < events . length ; i ++ ) { const eventObj = events [ i ] , j = i ; // await oThis.processEventObj(eventObj); if ( oThis . parallelProcessingAllowed ( ) ) { promiseArray . push ( new Promise ( function ( onResolve , onReject ) { setTimeout ( function ( ) { oThis . processEventObj ( eventObj ) . then ( onResolve ) . catch ( function ( error ) { logger . error ( '##### inside catch block #####: ' , error ) ; return onResolve ( ) ; } ) ; } , ( j * 1000 + 100 ) ) ; } ) ) ; } else { await oThis . processEventObj ( eventObj ) . catch ( function ( error ) { logger . error ( 'inside catch block: ' , error ) ; return Promise . resolve ( ) ; } ) ; } } if ( oThis . parallelProcessingAllowed ( ) ) { await Promise . all ( promiseArray ) ; } oThis . updateIntercomDataFile ( ) ; return Promise . resolve ( ) ; }
Process events array

@param {array} events - events array
Process events array