@stackend/api
Version:
JS bindings to api.stackend.com
50 lines • 1.6 kB
TypeScript
export interface PaginatedCollection<T> {
page: number;
pageSize: number;
totalSize: number;
hasNextPage: boolean;
hasPreviousPage: boolean;
lastPage: number;
firstPage: number;
nextPage: number;
previousPage: number;
entries: Array<T>;
}
/**
* Construct a new paginated collection.
*
* @param entries Entries (optional, default empty).
* @param page Page number (optional, default 1)
* @param pageSize Page size (optional, default 10)
* @param totalSize Total size (optional, taken from entries)
*/
export declare function newPaginatedCollection<T>({ entries, page, pageSize, totalSize }: {
entries?: Array<T>;
page?: number;
pageSize?: number;
totalSize?: number;
}): PaginatedCollection<T>;
/**
* Construct a new empty paginated collection.
* @param pageSize
*/
export declare function emptyPaginatedCollection<T>(pageSize?: number): PaginatedCollection<T>;
/**
* Create a new paginated collection given an array of all entries. Only the current page will be included in the pagination
* @param entries All entries
* @param page
* @param pageSize
*/
export declare function newPaginatedCollectionForPage<T>({ entries, page, pageSize }: {
entries?: Array<T>;
page?: number;
pageSize?: number;
}): PaginatedCollection<T>;
/**
* From a list, extract the entries making up the page using the page size
* @param entries
* @param page
* @param pageSize
*/
export declare function getEntriesOfPage<T>(entries: Array<T>, page: number, pageSize: number): Array<T>;
//# sourceMappingURL=PaginatedCollection.d.ts.map