@jiminp/tooltool
    Preparing search index...

    Function forEachPage

    • Fetches multiple pages in parallel and invokes a callback for each non-nullish page.

      Type Parameters

      • Page

        The page data type.

      Parameters

      • fetcher: PageFetcher<Page>

        Fetches a page by zero-based index.

      • callback: (page: NonNullable<Page>, index: number) => void

        Called for each non-nullish page (may be out-of-order).

      Returns Promise<void>

      Resolves when all pages are fetched.

      All pages are fetched in parallel with no concurrency limit; consider using rateLimited to wrap the fetcher. If a page reports a higher num_pages, additional pages are fetched automatically.

      Rejects immediately if any fetch fails; in-flight fetches continue but are ignored.

      await forEachPage(
      async (i) => ({ num_pages: 5, page: await fetchUsers(i) }),
      (users, i) => console.log(`Page ${i}:`, users),
      );

      fetchPages for an async generator alternative.