aws/aws-sdk-js — pull request #201 by evansolomon (2013-12-11 10:21:30+00:00)
Title: Support serial eachPage() operations

The `eachPage()` request helper is very cool, but I'm not sure I always want it to go as fast as possible. If there are many pages, then it could trigger lots of potentially expensive callbacks all at once. I think it would be cool if it acted a bit like a stream that waited for the data to be consumed.

This is a work in progress, so I'm curious to hear what you think. I realize that the same thing could be done by writing my own wrappers around paging, but since `eachPage` is already there I'd like to use it if I can. I'd also like to do the same with `eachItem`, but I haven't started working on it yet because pausing the consumption is a little bit trickier since there's no natural point to stop for i/o between items and I didn't want to start pulling in outside dependencies for queue or async management before seeing if you're interested in the idea at all.

The main idea is to be able to do something like this.

```javascript
s3.listObjects(params).eachPage(function (err, data, done) {
doSomethingAsyncAndOrExpensive(data, function () {
// The next page of results isn't fetched until now
done()
});
});
```