AniLink - v3.0.0
    Preparing search index...

    Function fetchNumericWithLookAhead

    • Numeric-mode look-ahead driver: keys are computable without any response, so a window of at most concurrency launched-but-unconsumed requests overlaps round-trip latency while results are appended strictly in entry order. The window steps up instead of filling cold: the first entry launches alone, and the window steps to the full concurrency only after a consumed entry confirms more data exists, so a traversal that ends at its first entry costs one request instead of concurrency requests' worth of rate-limit quota. Scheduling stops as soon as an entry reports "no more data" or the maxEntries guard fires; already-launched stragglers are drained and discarded. When extractBound is supplied (AniList page traversals pass extractLastPageBound), scheduling also never launches an entry numbered beyond the smallest positive bound a received entry reported: those requests were going to be drained and discarded anyway, so skipping them keeps their quota spend off the wire. A traversal the bound ends while the last consumed entry still reports more data returns truncated: true so the short read is not mistaken for a clean end. Traversals whose entries carry no page numbers (chunks) omit extractBound and leave the existing guards in charge. An abort settles in-flight requests and returns the collected prefix as a partial result with truncated: false.

      Type Parameters

      • TEntry

        The raw response shape of a single page or chunk.

      Parameters

      • fetch: (page: number) => Promise<TEntry>

        Callback that fetches a single entry given its numeric key.

      • extractHasMore: (response: TEntry) => boolean

        Reads the "more data available" flag from a fetched entry.

      • startNumber: number

        The 1-based page number to start from.

      • maxEntries: number

        Hard cap on entries fetched, guarding against unbounded loops.

      • concurrency: number

        Maximum number of requests kept in flight at once.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the traversal.

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

        Optional reader for the terminal page bound a fetched entry reports (AniList's pageInfo.lastPage); omit it for chunk-style traversals whose entries carry no page numbers.

      Returns Promise<LookAheadResult<TEntry>>

      The responses in entry order, how many were fetched, and whether the guard or a reported bound truncated the run.

      The rejection from the next unconsumed fetch call in entry order, unless the signal aborted.