UNPKG

mercadopago

Version:
30 lines (29 loc) 1.22 kB
/** * Auto-paging utilities for MercadoPago search endpoints. * * Returns an `AsyncIterable<T>` that lazily fetches pages of results so * callers can iterate over every item with a `for await...of` loop without * manually managing offset/limit. * * Example: * ```ts * const payment = new Payment(config); * for await (const p of payment.searchAll({ status: 'approved' })) { * console.log(p.id); * } * ``` */ import type { PageResult } from './types'; type SearchFn<TResult, TOptions> = (options?: TOptions) => Promise<PageResult<TResult>>; /** * Creates an `AsyncIterable<TResult>` that auto-fetches all pages. * * Supports both offset/limit pagination (Pattern A) and page/page_size * pagination (Pattern B, used by some Order endpoints). * * @param searchFn Callable that accepts search options and returns one page. * @param baseOptions Initial search options. `limit`/`offset` are managed automatically. * @param pageSize Items per page. Defaults to 100. */ export declare function createAutoPagingIterable<TResult, TOptions extends Record<string, unknown>>(searchFn: SearchFn<TResult, TOptions>, baseOptions?: TOptions, pageSize?: number): AsyncIterable<TResult>; export {};