Releases: seasonedcc/pagination-helpers
Releases · seasonedcc/pagination-helpers
Release list
v0.1.0
Initial release of pagination-helpers — zero-dependency pagination math primitives.
New Features
getPageCount({ total, perPage })— returns the number of pages (Math.ceil(total / perPage)); returns0whentotalis0.getPageRange({ page, pageCount, pagesAroundCurrent?, pagesAtEdges? })— returns the sequence of page numbers (with ellipses) to render in a pagination control. Output always starts with the firstpagesAtEdgespages and ends with the lastpagesAtEdgespages, withpagesAroundCurrentpages on either side ofpage. Gaps surface as'ellipsis-before'or'ellipsis-after', and single-page gaps fill in with the missing page instead of an ellipsis. The two ellipsis variants give consumers stable React keys without falling back to array index.getDisplayRange({ page, perPage, total })— returns the 1-based{ from, to }item range shown on the current page, useful for "Showing X to Y of Z results" labels. Returns{ from: 0, to: 0 }when there are no items to show.PageRangeItemtype — exported asnumber | 'ellipsis-before' | 'ellipsis-after'.
Highlights
- Zero runtime dependencies.
- Pure functions — no state, no I/O, trivially testable.
- Atomic primitives: pick the function you need, ignore the rest.
- Full TypeScript support.
- Ships ESM and CommonJS builds with type declarations.
Full Changelog: https://github.com/seasonedcc/pagination-helpers/commits/v0.1.0