Bitbucket Data Center API Client
    Preparing search index...

    Function paginate

    • Lazily iterates over every item across all pages of a paginated Bitbucket endpoint, following nextPageStart until isLastPage is reached.

      Type Parameters

      Parameters

      • fetchPage: (params: P) => Promise<PagedResponse<T>>

        A function that fetches a single page given a start offset, typically a bound client/resource method (e.g. (params) => bb.projects(params))

      • Optionalparams: P

        Base parameters passed to every page request (e.g. limit, filters)

      Returns AsyncGenerator<T, void, void>

      for await (const project of paginate((params) => bb.projects(params), { limit: 50 })) {
      console.log(project.key);
      }

      const prs = await bb.project('PROJ').repo('my-repo').pullRequests();
      for await (const pr of paginate(
      (params) => bb.project('PROJ').repo('my-repo').pullRequests(params),
      { state: 'OPEN' },
      )) {
      console.log(pr.id);
      }