AniLink - v3.0.0
    Preparing search index...

    Function malPaginatePages

    • Yields MyAnimeList list pages until the list ends or the maxPages limit is reached. The generator has no truncation flag. A terminal page has no paging.next URL, or is short when the response has no paging node. If the limit stops traversal, the last yielded page was full.

      Use this generator when you do not need to collect every item in memory or want to stop early. The maxPages limit bounds requests. The generator keeps up to concurrency page requests in flight. The default is 1, so requests run sequentially because MAL's rate limit makes look-ahead counterproductive. The generator yields pages in order. If the consumer exits early, a terminal page arrives, or the limit is reached, it waits for already-launched requests and discards their results.

      The shared streamNumericPages engine handles the launch window, terminal page drain, abort bridging, and early-exit cancellation. MAL supplies the terminal predicate: a page ends traversal when it has no paging.next URL, is short without a paging node, or has malformed data. The generator uses the same onPage, onHookError, and diagnostics options as malPaginate. It calls onPage once per yielded page.

      Type Parameters

      • TItem

        The list entry shape of the paginated endpoint.

      Parameters

      • fetchPage: (page: number, perPage: number, signal?: AbortSignal) => Promise<MalPage<TItem>>

        Callback that fetches a single page given its 1-based number, perPage, and an optional AbortSignal forwarded from the traversal; return the raw MAL list response ({ data, paging? }).

      • Optionaloptions: MalPaginateOptions

        Optional perPage, startPage, maxPages, concurrency, signal, onPage, onHookError, and diagnostics controls.

      Returns AsyncGenerator<MalPage<TItem>>

      Each raw MAL list page in turn, in page order.

      for await (const page of aniLink.mal.paginatePages(
      (page, perPage) => aniLink.mal.user.animeList({
      username: "@me",
      limit: perPage,
      offset: (page - 1) * perPage,
      })
      )) {
      console.log(page.data.length);
      }