lib/request.js
function eachPage(callback) {
    // Make all callbacks async-ish
    callback = AWS.util.fn.makeAsync(callback, 3);

    function wrappedCallback(response) {
      callback.call(response, response.error, response.data, function (result) {
        if (result === false) return;

        if (response.hasNextPage()) {
          response.nextPage().on('complete', wrappedCallback).send();
        } else {
          callback.call(response, null, null, AWS.util.fn.noop);
        }
      });
    }

    this.on('complete', wrappedCallback).send();
  }
function eachPage(callback) {
    // Make all callbacks async-ish
    callback = AWS.util.fn.makeAsync(callback, 3);

    function wrappedCallback(response) {
      callback.call(response, response.error, response.data, function (result) {
        if (result === false) return;

        if (response.hasNextPage()) {
          response.nextPage().on('complete', wrappedCallback).send();
        } else {
          callback.call(response, null, null, AWS.util.fn.noop);
        }
      });
    }

    this.on('complete', wrappedCallback).send();
  }
function eachPage ( callback ) { // Make all callbacks async-ish callback = AWS . util . fn . makeAsync ( callback , 3 ) ; function wrappedCallback ( response ) { callback . call ( response , response . error , response . data , function ( result ) { if ( result === false ) return ; if ( response . hasNextPage ( ) ) { response . nextPage ( ) . on ( 'complete' , wrappedCallback ) . send ( ) ; } else { callback . call ( response , null , null , AWS . util . fn . noop ) ; } } ) ; } this . on ( 'complete' , wrappedCallback ) . send ( ) ; }
Iterates over each page of results given a pageable request, calling
the provided callback with each page of data. After all pages have been
retrieved, the callback is called with `null` data.

@note This operation can generate multiple requests to a service.
@example Iterating over multiple pages of objects in an S3 bucket
var pages = 1;
s3.listObjects().eachPage(function(err, data) {
if (err) return;
console.log("Page", pages++);
console.log(data);
});
@example Iterating over multiple pages with an asynchronous callback
s3.listObjects(params).eachPage(function(err, data, done) {
doSomethingAsyncAndOrExpensive(function() {
// The next page of results isn't fetched until done is called
done();
});
});
@callback callback function(err, data, [doneCallback])
Called with each page of resulting data from the request. If the
optional `doneCallback` is provided in the function, it must be called
when the callback is complete.

@param err [Error] an error object, if an error occurred.
@param data [Object] a single page of response data. If there is no
more data, this object will be `null`.
@param doneCallback [Function] an optional done callback. If this
argument is defined in the function declaration, it should be called
when the next page is ready to be retrieved. This is useful for
controlling serial pagination across asynchronous operations.
@return [Boolean] if the callback returns `false`, pagination will
stop.

@see AWS.Request.eachItem
@see AWS.Response.nextPage
@since v1.4.0
Iterates over each page of results given a pageable request calling the provided callback with each page of data . After all pages have been retrieved the callback is called with null data .