in functions/src/github.ts [246:279]
async function paginate<S extends PageParams, T>(
fn: GitHubFn<S, Array<T>>,
options: S
): Promise<T[]> {
const per_page = 100;
let pagesRemaining = true;
let page = 0;
let allData = [] as T[];
while (pagesRemaining) {
page++;
// Merge pagination options with the options passed in
const pageOptions = Object.assign(
{
per_page,
page
},
options
);
const res = await fn(pageOptions);
allData = allData.concat(res.data);
// We assume another page remaining if we got exactly as many
// issues as we asked for.
pagesRemaining = res.data.length == per_page;
// Wait 0.5s between pages
await util.delay(0.5);
}
return allData;
}