function visitUsers(userIds, visitor) {
    var deferred = $.Deferred();
    var users = userIds.splice(0);
    var request = _(requestTemplate).clone();
    
    function sendQuery() {
      request.user_ids = users.splice(0, requestCollectionMax);
      serviceRequest('query_users', request).done(doneQuery).fail(failQuery);
    }
    
    function doneQuery(response) {
      var isLastQuery = (users.length === 0);
      
      // Send out request for the next page of data, if it exists.
      if (!isLastQuery) sendQuery();
      
      // Invoke the visitor with the returned data for this viewpoint.
      _(response.users).each(visitor);
      
      // If this was the last page of the query, resolve this method's promise.
      if (isLastQuery) deferred.resolve();
    }
    
    function failQuery(jqHxr, textStatus) {
      deferred.reject('Error from visitUsers: ' + textStatus);
    }
    
    sendQuery();
    return deferred;
  }
/**
   * Queries the service for user metadata and invokes the visitor function once with each 
   * user returned.  Paging is handled transparently by this function.
   *
   * @memberof viewfinder.query
   * @param {Number[]} userIds A list of viewfinder UserIds for which metadata is desired.
   * @param {Function} visitor A visitor function which will be invoked once for each user
   *   returned by the query.
   * 
   * @returns {jQuery.Deferred} A jQuery deferred object which will resolve when all user data has
   *   been visited.
   */
Queries the service for user metadata and invokes the visitor function once with each
user returned.  Paging is handled transparently by this function.

@memberof viewfinder.query
@param {Number[]} userIds A list of viewfinder UserIds for which metadata is desired.
@param {Function} visitor A visitor function which will be invoked once for each user
returned by the query.

@returns {jQuery.Deferred} A jQuery deferred object which will resolve when all user data has
been visited.
Queries the service for user metadata and invokes the visitor function once with each user returned . Paging is handled transparently by this function . @memberof viewfinder . query @param { Number [] } userIds A list of viewfinder UserIds for which metadata is desired . @param { Function } visitor A visitor function which will be invoked once for each user returned by the query . @returns { jQuery . Deferred } A jQuery deferred object which will resolve when all user data has been visited .
function visitUsers(userIds, visitor) {
    var deferred = $.Deferred();
    var users = userIds.splice(0);
    var request = _(requestTemplate).clone();
    function sendQuery() {
      request.user_ids = users.splice(0, requestCollectionMax);
      serviceRequest('query_users', request).done(doneQuery).fail(failQuery);
    }
    function doneQuery(response) {
      var isLastQuery = (users.length === 0);
      if (!isLastQuery) sendQuery();
      _(response.users).each(visitor);
      if (isLastQuery) deferred.resolve();
    }
    function failQuery(jqHxr, textStatus) {
      deferred.reject('Error from visitUsers: ' + textStatus);
    }
    sendQuery();
    return deferred;
  }
function visitUsers ( userIds , visitor ) { var deferred = $ . Deferred ( ) ; var users = userIds . splice ( 0 ) ; var request = _ ( requestTemplate ) . clone ( ) ; function sendQuery ( ) { request . user_ids = users . splice ( 0 , requestCollectionMax ) ; serviceRequest ( 'query_users' , request ) . done ( doneQuery ) . fail ( failQuery ) ; } function doneQuery ( response ) { var isLastQuery = ( users . length === 0 ) ; if ( ! isLastQuery ) sendQuery ( ) ; _ ( response . users ) . each ( visitor ) ; if ( isLastQuery ) deferred . resolve ( ) ; } function failQuery ( jqHxr , textStatus ) { deferred . reject ( 'Error from visitUsers: ' + textStatus ) ; } sendQuery ( ) ; return deferred ; }
Queries the service for user metadata and invokes the visitor function once with each
 user returned.
Queries the service for user metadata and invokes the visitor function once with each user returned .
// Send out request for the next page of data, if it exists. // Invoke the visitor with the returned data for this viewpoint. // If this was the last page of the query, resolve this method's promise.