Function makePager

  • Create an AsyncIterable that iterates across pages using the provided fetcher.

    Type Parameters

    • T

    Parameters

    • fetchPage: ((cursor?: any) => Promise<Paged<T>>)
        • (cursor?): Promise<Paged<T>>
        • Parameters

          • Optionalcursor: any

          Returns Promise<Paged<T>>

    Returns AsyncIterable<T>

    // Example: stream recent blocks using GET /blocks?limit=5&before=HEIGHT
    const firstPage = await client.listBlocks({ limit: 5 });
    for await (const b of firstPage.asIterable()) {
    console.log(b.height, b.hash);
    }