AniLink - v3.0.0
    Preparing search index...

    Interface MalPaginateOptions

    Options controlling a malPaginate or malPaginatePages traversal.

    interface MalPaginateOptions {
        concurrency?: number;
        diagnostics?: DiagnosticsMode;
        maxPages?: number;
        onHookError?: OnHookErrorHandler;
        onPage?: (
            page: { items: unknown[]; paging: MalPaging | undefined },
        ) => void;
        perPage?: number;
        signal?: AbortSignal;
        startPage?: number;
    }
    Index
    concurrency?: number

    Maximum number of page requests kept in flight at once while collecting results. Pages are always returned in order regardless of completion order, scheduling stops as soon as a fetched page reports the end of the list (a paging node with no next URL, or a short page when the response carries no paging node), and every existing guard (maxPages, perPage clamping) still applies. Defaults to 1 (strictly sequential) because MAL's rate limit of 1 to 2 requests per second makes look-ahead counterproductive; values above 8 are clamped down to 8.

    diagnostics?: DiagnosticsMode

    Controls how a throwing onPage callback with no onHookError observer is reported: "warn" (default) emits a structured console.warn record, "hook" requires the observer and never touches the console, and "silent" suppresses the report entirely.

    maxPages?: number

    Hard cap on pages fetched, guarding against unbounded loops. Defaults to 100, which means up to 100 round-trips (up to 10,000 items at the default perPage); set an explicit value for cost-sensitive workloads.

    onHookError?: OnHookErrorHandler

    Optional observer for failures thrown by the MalPaginateOptions.onPage callback. When provided, a throwing onPage callback is reported to this handler with the hook name ("onPage") and the thrown error instead of falling back to console.warn. Failures thrown by the observer itself are swallowed so a broken logger cannot fail the traversal.

    onPage?: (page: { items: unknown[]; paging: MalPaging | undefined }) => void

    Optional callback invoked once per page after malPaginate collects all responses. The callback receives the page's paging node and items array. This function still returns the full MalPaginateResult, so the callback does not reduce peak memory or yield items incrementally. Use malPaginatePages to process pages as they arrive or stop early with break or return. Errors thrown by the callback are caught and reported through MalPaginateOptions.onHookError when configured, or through console.warn otherwise. The traversal continues.

    perPage?: number

    Entries requested per page. Values above 100, the most restrictive documented cap across MAL's list endpoints, are clamped down to 100. Defaults to 100.

    signal?: AbortSignal

    Optional AbortSignal to cancel the traversal. When aborted, all in-flight look-ahead page requests are cancelled immediately so they stop consuming rate-limit budget and bandwidth for payloads that will be discarded. The signal is also forwarded to fetchPage calls so the transport layer can abort the underlying HTTP request.

    startPage?: number

    1-based page number to start from. The closure's offset math follows the start page: startPage: 3 starts at offset = 2 * perPage. Defaults to 1.