Skip to content

Page<T>

Una página de resultados.

Se comporta como una secuencia: page.length, page.items[0], for (const x of page) recorren solo esta página. Para recorrer todas:

ts
const primera = await sd.invoices.list();
for await (const factura of primera.autoPaging()) { ... }

Type Parameters

Type Parameter
T

Implements

  • Iterable<T>

Constructors

Constructor

ts
new Page<T>(options): Page<T>;

Parameters

ParameterType
options{ items: readonly T[]; nextCursor?: string; hasMore?: boolean; limit?: number; fetchNext?: (cursor) => Promise<Page<T>>; }
options.itemsreadonly T[]
options.nextCursor?string
options.hasMore?boolean
options.limit?number
options.fetchNext?(cursor) => Promise<Page<T>>

Returns

Page<T>

Properties

items

ts
readonly items: readonly T[];

nextCursor

ts
readonly nextCursor: string | undefined;

hasMore

ts
readonly hasMore: boolean;

limit

ts
readonly limit: number;

Accessors

length

Get Signature

ts
get length(): number;
Returns

number


first

Get Signature

ts
get first(): T | undefined;

El primer elemento, o undefined si la página vino vacía.

Returns

T | undefined

Methods

[iterator]()

ts
iterator: Iterator<T>;

Returns

Iterator<T>

Implementation of

ts
Iterable.[iterator]

nextPage()

ts
nextPage(): Promise<Page<T> | undefined>;

La página siguiente, o undefined si esta era la última.

Returns

Promise<Page<T> | undefined>


autoPaging()

ts
autoPaging(): AsyncGenerator<T, void, undefined>;

Recorre todos los resultados, siguiendo el cursor solo.

El transporte regula a 5 solicitudes por segundo, así que recorrer un listado largo es lento pero no dispara 429.

Returns

AsyncGenerator<T, void, undefined>


all()

ts
all(): Promise<T[]>;

Todos los resultados en un array. Cuidado con los listados largos.

Returns

Promise<T[]>


fromResult()

ts
static fromResult<T>(
   items, 
   pagination, 
fetchNext?): Page<T>;

Type Parameters

Type Parameter
T

Parameters

ParameterType
itemsreadonly T[]
paginationPagination | undefined
fetchNext?(cursor) => Promise<Page<T>>

Returns

Page<T>