Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 91x 91x 91x 91x 180x 180x | export function getPagination(page = 1, limit = 20) {
const safePage = Math.max(1, page);
const safeLimit = Math.min(100, Math.max(1, limit));
const offset = (safePage - 1) * safeLimit;
return { offset, limit: safeLimit, page: safePage };
}
export function buildPaginationMeta(
total: number,
page: number,
limit: number,
) {
const totalPages = Math.ceil(total / limit);
return {
total,
page,
limit,
totalPages,
hasNext: page < totalPages,
hasPrev: page > 1,
};
}
|