index/functions/calculateTotalPages.md
calculateTotalPages(
total,limit):number
Calculate total pages from total count and limit
Determines how many pages are needed to display all items. Useful for pagination UI and progress tracking.
Parameters
| Parameter | Type | Description |
|---|---|---|
total | number | Total number of items |
limit | number | Items per page |
Returns
number
Number of pages needed
Throws
Error if total or limit is invalid
Example
calculateTotalPages(100, 20) // Returns: 5
calculateTotalPages(105, 20) // Returns: 6 (partial page)
calculateTotalPages(0, 20) // Returns: 0 (no items)
calculateTotalPages(20, 20) // Returns: 1
Since
6.5.0