Skip to main content

Paginator - Paginate with minimal efforts

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​

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 ≥ 0
    • itemsPerPage ≥ 1
    • currentPage ≥ 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'>;