Async-iterates one page at a time. Stops when fetcher returns nextCursor: undefined.
fetcher
nextCursor: undefined
The per-page response shape.
The cursor type used to request the next page.
Function that fetches one page given the current cursor.
Optional abort signal. Checked before each fetch.
An async iterable of pages.
DOMException When signal is aborted between fetches.
signal
for await (const page of paginatePages( async (cursor) => { const resp = await bucket.listFileNames({ startFileName: cursor }) return { page: resp, nextCursor: resp.nextFileName ?? undefined } }, abortSignal,)) { for (const file of page.files) { ... }} Copy
for await (const page of paginatePages( async (cursor) => { const resp = await bucket.listFileNames({ startFileName: cursor }) return { page: resp, nextCursor: resp.nextFileName ?? undefined } }, abortSignal,)) { for (const file of page.files) { ... }}
Async-iterates one page at a time. Stops when
fetcherreturnsnextCursor: undefined.