Pagination Utility is based on the KISS (Keep it Simple, Stupid) principle. It is a simple library which can help you out to make pagination functionality in an easy way.
$ npm install pagination-utility --save
import { PaginationUtility } from 'pagination-utility';
// @returns { limit, offset }
const { limit, offset } = PaginationUtility.getValuesToPaginate({ currentPage: 1, perPage: 10 });
// Do stuff...
// - Get collection from database using limit and offset (this should return the total of items, it will be used in the next step)
// @return totalPages
const totalPages = PaginationUtility.getTotalPages({ totalItems: 4872, perPage: 10 })
// return
// {
// collection,
// currentPage,
// perPage,
// totalPages
// }