lib/utils.js
function collectPages(func, callback) {
    var items = [];
    var lastReadId = 0;
    function __collect() {
        return func(lastReadId, function(error, page) {
            if (error) {
                return callback(error);
            }
            if (!page.length) {
                return callback(null, items);
            }
            items = items.concat(page);
            lastReadId = page[page.length - 1].id;
            return __collect();
        });
    }
    return __collect();
}
function collectPages(func, callback) {
    var items = [];
    var lastReadId = 0;
    function __collect() {
        return func(lastReadId, function(error, page) {
            if (error) {
                return callback(error);
            }
            if (!page.length) {
                return callback(null, items);
            }
            items = items.concat(page);
            lastReadId = page[page.length - 1].id;
            return __collect();
        });
    }
    return __collect();
}
function collectPages ( func , callback ) { var items = [ ] ; var lastReadId = 0 ; function __collect ( ) { return func ( lastReadId , function ( error , page ) { if ( error ) { return callback ( error ) ; } if ( ! page . length ) { return callback ( null , items ) ; } items = items . concat ( page ) ; lastReadId = page [ page . length - 1 ] . id ; return __collect ( ) ; } ) ; } return __collect ( ) ; }
Helper function for collecting all pages of items.

@param  {Function} func(lastReadId, next) Function invoked to fetch requests
@param  {Object} callback(error, items) Function invoked once all pages have been fetched
Helper function for collecting all pages of items .