iteratePages
iteratePages<
T>(fetchPage,pageSize?):AsyncGenerator<T>
Defined in: packages/core/src/pagination/PaginationHelper.ts:115
Async generator for memory-efficient iteration over offset-paginated results.
Yields one item at a time, fetching the next page on demand. Use this instead
of collectAllPages when result sets may be large or when you want to
stop early (e.g. break out of the loop once a match is found).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”fetchPage
Section titled “fetchPage”(startAt, maxResults) => Promise<OffsetPage<T>>
A function that fetches one page given startAt and maxResults
pageSize?
Section titled “pageSize?”number = 50
Number of items to request per page (default: 50)
Returns
Section titled “Returns”AsyncGenerator<T>
Example
Section titled “Example”import { iteratePages } from '@forge-clients/core';import { searchForIssuesUsingJql } from '@forge-clients/jira/v3';
for await (const issue of iteratePages( (startAt, maxResults) => searchForIssuesUsingJql(client, { body: { jql: 'project = PROJ', startAt, maxResults } }),)) { console.log(issue.key); if (issue.key === 'PROJ-42') break; // stop early without fetching remaining pages}