pagination-utility
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Pagination Utility

npm code style: prettier

Intro

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.

Install

$ npm install pagination-utility --save

Usage

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
// }

License

License: MIT

Package Sidebar

Install

npm i pagination-utility

Weekly Downloads

12

Version

0.1.3

License

MIT

Unpacked Size

13.1 kB

Total Files

12

Last publish

Collaborators

  • salatiel