- Automatic iteration with
for await...ofloops - Manual page control with
fetchNext()andfetchPrevious() - Metadata access for pagination tokens and counts
- Error handling and rate limit detection
- Support for both forward and backward pagination
Example
Example
Parâmetros de tipo
Hierarquia
-
Paginator↳PostPaginator↳UserPaginator↳EventPaginator
Implements
AsyncIterable<T>
Construtores
constructor
• new Paginator<T>(fetchPage): Paginator<T>
Creates a new paginator instance
Parâmetros de tipo
Parâmetros
Retorna
Paginator<T>
Definido em
paginator.ts:90Acessadores
items
•get items(): T[]
Get all fetched items
Retorna
T[]
Definido em
paginator.ts:97meta
•get meta(): any
Get current pagination metadata
Retorna
any
Definido em
paginator.ts:104includes
•get includes(): undefined | Record<string, any>
Get current includes data
Retorna
undefined | Record<string, any>
Definido em
paginator.ts:111errors
•get errors(): undefined | any[]
Get current errors
Retorna
undefined | any[]
Definido em
paginator.ts:118done
•get done(): boolean
Check if pagination is done
Retorna
boolean
Definido em
paginator.ts:125rateLimited
•get rateLimited(): boolean
Check if rate limit was hit
Retorna
boolean
Definido em
paginator.ts:132Métodos
fetchNext
▸ fetchNext():Promise<void>
Fetch the next page and add items to current instance
This method fetches the next page of data and appends the items to the
current paginator instance. It updates the pagination state and metadata.
Retorna
Promise<void>
Example
Throws
When the API request fails
Definido em
paginator.ts:156next
▸ next():Promise<Paginator<T>>
Get next page as a new instance
This method creates a new paginator instance that starts from the next page,
without affecting the current paginator’s state.
Retorna
Promise<Paginator<T>>
New paginator instance for the next page
Example
Definido em
paginator.ts:211fetchPrevious
▸ fetchPrevious():Promise<void>
Fetch previous page (if supported)
Retorna
Promise<void>
Definido em
paginator.ts:225previous
▸ previous():Promise<Paginator<T>>
Get previous page as a new instance
Retorna
Promise<Paginator<T>>
Definido em
paginator.ts:260fetchLast
▸ fetchLast(count): Promise<void>
Fetch up to a specified number of additional items
Parâmetros
Retorna
Promise<void>
Definido em
paginator.ts:274reset
▸ reset():void
Reset paginator to initial state
Retorna
void
Definido em
paginator.ts:288[iterator]
▸ [iterator]():Iterator<T, any, undefined>
Iterator for all fetched items
Retorna
Iterator<T, any, undefined>
Definido em
paginator.ts:303[asyncIterator]
▸ [asyncIterator]():AsyncIterator<T, any, undefined>
Async iterator that fetches pages automatically
Retorna
AsyncIterator<T, any, undefined>