Paginator - Paginate with minimal efforts
API Reference for Paginator
This documentation provides complete coverage of all methods in the Paginator
class, organized into logical categories with detailed sections for each method.
Table of Contents
- Constructor
- Instance Creation Methods
- Pagination Calculation Methods
- Page Navigation Methods
- Utility Methods
- Static Methods
Constructor
constructor()
Signature
constructor(options: PaginatorOptions)
Parameters
options
: Pagination configuration
interface PaginatorOptions {
totalItems: Numeric;
itemsPerPage?: Numeric; // default: 10
currentPage?: Numeric; // default: 1
}
Behavior
- Initializes paginator with provided values
- Applies safety clamping:
totalItems
≥ 0itemsPerPage
≥ 1currentPage
≥ 1
Example
new Paginator({
totalItems: 100,
itemsPerPage: 10,
currentPage: 3
});
Type Definitions
Numeric
type Numeric = number | `${number}`;
Union type accepting numbers or numeric strings
PaginatorOptions
interface PaginatorOptions {
totalItems: Numeric;
itemsPerPage?: Numeric;
currentPage?: Numeric;
}
Initialization options with defaults
PaginatorMeta
interface PaginatorMeta {
totalItems: number;
currentPage: number;
itemsPerPage: number;
totalPages: number;
hasPrev: boolean;
hasNext: boolean;
isFirst: boolean;
isLast: boolean;
offset: number;
}
Complete pagination metadata
PageListOptions
interface PageListOptions {
edgeCount?: number;
siblingCount?: number;
}
Page list generation options
FromMetaOptions
type FromMetaOptions = Pick<PaginatorMeta, 'totalItems' | 'itemsPerPage' | 'currentPage'>;