lib/connection/result/result.js
function()
    {
      // get the start position and start time
      var startIndex = rowIndex;
      var startTime  = Date.now();

      var each = options.each;
      while (rowIndex < rowsLength)
      {
        // invoke the each() callback on the current row
        var ret = each(rows[rowIndex++]);

        context.numRowsProcessed++;

        // if the callback returned false, stop processing rows
        if (ret === false)
        {
          var stoppedProcessingRows = true;
          break;
        }

        // use the current position and current time to check if we've been
        // processing rows for too long; if so, leave the rest for the next
        // tick of the event loop
        if ((rowIndex - startIndex) >= context.rowBatchSize &&
            (Date.now() - startTime) > context.rowBatchDuration)
        {
          process.nextTick(processRows);
          break;
        }
      }

      // if there are no more rows for us to process in this chunk
      if (!(rowIndex < rowsLength) || stoppedProcessingRows)
      {
        // if we exhausted all the rows in this chunk and we haven't yet
        // processed all the rows we want to process, ask the result stream to
        // do another read
        if (!(rowIndex < rowsLength) &&
            context.numRowsProcessed !== context.maxNumRowsToProcess)
        {
          resultStream.read();
        }
        else
        {
          // we've either processed all the rows we wanted to process or we
          // were told to stop processing rows by the each() callback; either
          // way, close the result stream to complete the operation
          resultStream.asyncClose();
        }
      }
    }
function()
    {
      // get the start position and start time
      var startIndex = rowIndex;
      var startTime  = Date.now();

      var each = options.each;
      while (rowIndex < rowsLength)
      {
        // invoke the each() callback on the current row
        var ret = each(rows[rowIndex++]);

        context.numRowsProcessed++;

        // if the callback returned false, stop processing rows
        if (ret === false)
        {
          var stoppedProcessingRows = true;
          break;
        }

        // use the current position and current time to check if we've been
        // processing rows for too long; if so, leave the rest for the next
        // tick of the event loop
        if ((rowIndex - startIndex) >= context.rowBatchSize &&
            (Date.now() - startTime) > context.rowBatchDuration)
        {
          process.nextTick(processRows);
          break;
        }
      }

      // if there are no more rows for us to process in this chunk
      if (!(rowIndex < rowsLength) || stoppedProcessingRows)
      {
        // if we exhausted all the rows in this chunk and we haven't yet
        // processed all the rows we want to process, ask the result stream to
        // do another read
        if (!(rowIndex < rowsLength) &&
            context.numRowsProcessed !== context.maxNumRowsToProcess)
        {
          resultStream.read();
        }
        else
        {
          // we've either processed all the rows we wanted to process or we
          // were told to stop processing rows by the each() callback; either
          // way, close the result stream to complete the operation
          resultStream.asyncClose();
        }
      }
    }
function ( ) { // get the start position and start time var startIndex = rowIndex ; var startTime = Date . now ( ) ; var each = options . each ; while ( rowIndex < rowsLength ) { // invoke the each() callback on the current row var ret = each ( rows [ rowIndex ++ ] ) ; context . numRowsProcessed ++ ; // if the callback returned false, stop processing rows if ( ret === false ) { var stoppedProcessingRows = true ; break ; } // use the current position and current time to check if we've been // processing rows for too long; if so, leave the rest for the next // tick of the event loop if ( ( rowIndex - startIndex ) >= context . rowBatchSize && ( Date . now ( ) - startTime ) > context . rowBatchDuration ) { process . nextTick ( processRows ) ; break ; } } // if there are no more rows for us to process in this chunk if ( ! ( rowIndex < rowsLength ) || stoppedProcessingRows ) { // if we exhausted all the rows in this chunk and we haven't yet // processed all the rows we want to process, ask the result stream to // do another read if ( ! ( rowIndex < rowsLength ) && context . numRowsProcessed !== context . maxNumRowsToProcess ) { resultStream . read ( ) ; } else { // we've either processed all the rows we wanted to process or we // were told to stop processing rows by the each() callback; either // way, close the result stream to complete the operation resultStream . asyncClose ( ) ; } } }
create a function that can be called to batch-process rows
create a function that can be called to batch - process rows