AniLink - v3.0.0
    Preparing search index...

    Function streamNumericPages

    • Streaming numeric-page driver: the generator counterpart of fetchNumericWithLookAhead.

      Yields pages strictly in page order while keeping a window of at most concurrency launched-but-unconsumed requests in flight, so round-trip latency overlaps without reordering results. The window steps up like the eager driver's: the first page launches alone and the window steps to the full concurrency only after a yielded page is confirmed non-terminal, so a single-page traversal costs one request. Scheduling stops as soon as a fetched page is terminal per the caller-supplied isTerminalPage, at the maxPages guard, or, when extractBound is supplied, beyond the smallest launch bound a received page reported; already-launched stragglers are drained and their payloads discarded. On early exit (break/return by the consumer), the finally block disposes the abort bridge so unconsumed in-flight requests are cancelled instead of running to completion for payloads that will be discarded.

      A page rejection propagates to the consumer unless the traversal signal aborted, in which case the generator ends after the already-yielded prefix. An already-aborted signal yields nothing.

      Type Parameters

      • TPage

        The raw response shape of a single page.

      Parameters

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

        Callback that fetches a single page given its 1-based number, perPage, and the traversal's AbortSignal.

      • isTerminalPage: (response: TPage) => boolean

        Reads the end-of-list signal from a fetched page; a terminal page is yielded, then the traversal ends.

      • options: StreamNumericPagesOptions

        The provider-resolved traversal options; see StreamNumericPagesOptions.

      • OptionalextractBound: (response: TPage) => number | undefined

        Optional reader for the terminal page bound a fetched page reports (AniList's pageInfo.lastPage); scheduling never launches a page numbered beyond the smallest reported bound.

      Returns AsyncGenerator<TPage>

      Each fetched page, in page order.