@felix-ongom/js-paginator
v1.1.5
Published
For paginating js array
Maintainers
Readme
js-paginator
This is a js library for paginating an array of data,
Installation
npm i @felix-ongom/js-paginatorUsage
const {paginate} = require('@felix-ongom/js-paginator')
paginate(array, {page:2, per_page:5})It returns an object containing data of current page and its metadats like.
{
page: 2, //current page
limit: 5, //number ot items on the page
has_next: true, //wheather it has next page or not
has_prev: true, //wheather it has previous page or not
next_page: 3, //what next page will be
prev_page: 1, //what previous page was
num_pages: 3 ,// total number of pages
data:[...],
position:6 //position of the first element of the data in the entire erray
}The default page is one and the default number per page is 12
