Boundary-safe pagination math
Calculates page totals and item ranges explicitly, including empty collections and partial final pages.
Day 034 / APIs / Pagination
A dependency-free Python CLI that calculates offset pagination, item bounds and an ellipsis-aware navigation window without requesting an API.
Calculates page totals and item ranges explicitly, including empty collections and partial final pages.
Keeps first and last pages visible while centering a bounded page-number window around the current position.
Simulates pagination arithmetic only; it fetches no records and documents when cursor pagination may be more suitable.
Offset and limit calculation
One-based item bounds
Previous and next page states
Ellipsis-aware navigation
Empty and partial-page handling
Twelve standard-library tests included
Argparse, dataclasses and JSON provide the complete dependency-free command-line workflow.
Models one-based pages, zero-based offsets, fixed limits, item ranges and navigation state.
Twelve tests cover exact and partial pages, empty data, invalid pages, navigation windows and CLI JSON output.