Skip to content

salatielosorno/pagination-utility

Repository files navigation

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

NPM

About

Utility to implement pagination functionality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published