import { IPaginationMeta } from './interface' import { Pagination } from './pagination' export function createPaginationObject({ items, totalItems, currentPage, limit, }: { items: T[] totalItems?: number currentPage: number limit: number }): Pagination { const totalPages = totalItems !== undefined ? Math.ceil(totalItems / limit) : undefined const meta: IPaginationMeta = { totalItems, itemCount: items.length, itemsPerPage: limit, totalPages, currentPage, } return new Pagination(items, meta) }