The raw response shape of a single page or chunk.
The paging key type: a page number in numeric mode, or an opaque cursor value in cursor mode.
Callback that fetches a single entry given its paging key.
Reads the "more data available" flag from a fetched entry. Return false for malformed responses so a broken payload ends the traversal instead of looping forever.
Positional paging arguments in one of two shapes: numeric paging [startNumber, maxEntries, concurrency], or cursor paging [extractNextKey, firstKey, maxEntries, concurrency] where extractNextKey reads the next paging key from a fetched entry (undefined selects numeric paging). Keys, caps, and the concurrency window are already resolved and validated when this driver is invoked.
The responses in entry order, how many were fetched, and whether the guard truncated the run.
Shared look-ahead driver for paged traversals.
Fetches entries through a sliding window of at most
concurrencylaunched- but-unconsumed requests so round-trip latency overlaps instead of stacking, while results are appended strictly in entry order no matter when each request settles. Scheduling stops as soon as an entry reports "no more data" (per the caller-suppliedextractHasMore) or themaxEntriesguard fires;truncatedmirrors the sequential semantics.Because the window runs ahead of consumption, up to
concurrency - 1already-launched requests may complete past a terminal entry; their payloads are drained and discarded so the collected prefix matches what a strictly sequential traversal would have returned.Two call shapes are supported:
Numeric paging (AniList pages and chunks):
fetchWithLookAhead(fetch, extractHasMore, undefined, startNumber, maxEntries, concurrency)or the shorthand five-argument formfetchWithLookAhead(fetch, extractHasMore, startNumber, maxEntries, concurrency). Keys advance by slot arithmetic (startNumber + slot).Cursor paging (MyAnimeList and any provider whose next key is carried by the previous response): pass an
extractNextKeycallback as the third argument. Each consumed entry supplies the key for its successor; the first key isfirstKey. Cursor mode never schedules past a terminal entry even if that entry still carries a stale next key.