@backblaze-labs/b2-sdk - v0.1.0
    Preparing search index...

    Function paginatePages

    • Async-iterates one page at a time. Stops when fetcher returns nextCursor: undefined.

      Type Parameters

      • Page

        The per-page response shape.

      • Cursor

        The cursor type used to request the next page.

      Parameters

      • fetcher: PageFetcher<Page, Cursor>

        Function that fetches one page given the current cursor.

      • signal: AbortSignal | undefined

        Optional abort signal. Checked before each fetch.

      Returns AsyncIterableIterator<Page>

      An async iterable of pages.

      DOMException When signal is aborted between fetches.

      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) { ... }
      }