Skip to main content
X API paginator with rich functionality This class provides comprehensive pagination support for the X API, including:
  • Automatic iteration with for await...of loops
  • Manual page control with fetchNext() and fetchPrevious()
  • Metadata access for pagination tokens and counts
  • Error handling and rate limit detection
  • Support for both forward and backward pagination
Example
Example

Type parameters

Jerarquía

Implements

  • AsyncIterable<T>

Constructores

constructor

new Paginator<T>(fetchPage): Paginator<T> Creates a new paginator instance

Parámetros de tipo

Parámetros

Devuelve

Paginator<T>

Definido en

paginator.ts:90

Accessors

items

get items(): T[] Get all fetched items

Devuelve

T[]

Definido en

paginator.ts:97

meta

get meta(): any Get current pagination metadata

Devuelve

any

Definido en

paginator.ts:104

includes

get includes(): undefined | Record<string, any> Get current includes data

Devuelve

undefined | Record<string, any>

Definido en

paginator.ts:111

errors

get errors(): undefined | any[] Get current errors

Devuelve

undefined | any[]

Definido en

paginator.ts:118

done

get done(): boolean Check if pagination is done

Devuelve

boolean

Definido en

paginator.ts:125

rateLimited

get rateLimited(): boolean Check if rate limit was hit

Devuelve

boolean

Definido en

paginator.ts:132

Mé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.

Devuelve

Promise<void> Example
Throws When the API request fails

Definido en

paginator.ts:156

next

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.

Devuelve

Promise<Paginator<T>> New paginator instance for the next page Example

Definido en

paginator.ts:211

fetchPrevious

fetchPrevious(): Promise<void> Fetch previous page (if supported)

Devuelve

Promise<void>

Definido en

paginator.ts:225

previous

previous(): Promise<Paginator<T>> Get previous page as a new instance

Devuelve

Promise<Paginator<T>>

Definido en

paginator.ts:260

fetchLast

fetchLast(count): Promise<void> Fetch up to a specified number of additional items

Parámetros

Devuelve

Promise<void>

Definido en

paginator.ts:274

reset

reset(): void Reset paginator to initial state

Devuelve

void

Definido en

paginator.ts:288

[iterator]

[iterator](): Iterator<T, any, undefined> Iterator for all fetched items

Devuelve

Iterator<T, any, undefined>

Definido en

paginator.ts:303

[asyncIterator]

[asyncIterator](): AsyncIterator<T, any, undefined> Async iterator that fetches pages automatically

Devuelve

AsyncIterator<T, any, undefined>

Implementation of

AsyncIterable.[asyncIterator]

Definido en

paginator.ts:312