Skip to content

Releases: seasonedcc/pagination-helpers

Release list

v0.1.0

Choose a tag to compare

@danielweinmann danielweinmann released this 27 Apr 22:33
2b3765a

Initial release of pagination-helpers — zero-dependency pagination math primitives.

New Features

  • getPageCount({ total, perPage }) — returns the number of pages (Math.ceil(total / perPage)); returns 0 when total is 0.
  • getPageRange({ page, pageCount, pagesAroundCurrent?, pagesAtEdges? }) — returns the sequence of page numbers (with ellipses) to render in a pagination control. Output always starts with the first pagesAtEdges pages and ends with the last pagesAtEdges pages, with pagesAroundCurrent pages on either side of page. 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.
  • PageRangeItem type — exported as number | '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