import { PaginationResponseDto } from './pagination-response.dto' ; import { PaginationRequest } from './interfaces' ; export class Pagination { param PaginationRequest { PaginationRequest } param totalRecords { number } param dtos { t [ ] } returns { PaginationResponseDto } static of < T > ( { limit , page , skip } , totalRecords , dtos ) { const totalPages = Math . floor ( totalRecords / limit ) + ( totalRecords % limit > 0 ? 1 : 0 ) ; const currentPage = + page > 0 ? + page : 1 ; const hasNext = currentPage <= totalPages - 1 ; return { totalPages : totalPages , payloadSize : dtos . length , hasNext : hasNext , content : dtos , currentPage : currentPage , skippedRecords : skip , totalRecords : totalRecords , } ; } }