@matheustrres/brasilapi
Version:
Lightweight, easy-to-use & free of dependencies wrapper for BrasilAPI
44 lines (43 loc) • 1.21 kB
TypeScript
/**
* @author matheustrres
* @see {@link [gist](https://gist.github.com/matheustrres/5d6b1647a547e009b33c1cb7117a7e27)}
*/
type PaginatorConfig<T> = {
items: T[];
itemsPerPage?: number;
take?: number;
skip?: number;
};
/**
* A facilitator for data pagination
*
* @prop {Number} itemsPerPage - The limit of items per page
*/
export declare class Paginator<T> {
#private;
itemsPerPage: number;
/**
* Create a new Paginator instance
*
* @param {PaginatorConfig<T>} config -The configuration options for Paginator
* @param {T[]} config.items - The items to be paginated
* @param {Number} config.itemsPerPage - The limit of items per page
* @param {Number} [config.take] - The number of items to be taken
* @param {Number} [config.skip] - The number of items to be skipped
*/
constructor({ items, itemsPerPage, skip, take }: PaginatorConfig<T>);
/**
* Load all pages and it's items
*
* @returns {T[][]}
*/
loadPages(): T[][];
/**
* Load a single page and it's items
*
* @param {Number} p - The page to be loaded
* @returns {T[]}
*/
loadPage(p?: number): T[];
}
export {};