README
var pagination = require('ap-pagination');
pagination.getPager(totalLength, currentPage, pageSize)
Create a new getPager function using the given totalLength, currentPage, pagesize. The format argument is number and the function will produce a json object.
Install:-
$ npm install ap-pagination
Examples:-
const pager = pagination.getPager(20, 1, 5);
console.log(pager); // => { totalItems: 20,
currentPage: 1,
pageSize: 5,
totalPages: 4,
startPage: 1,
endPage: 4,
startIndex: 0,
endIndex: 4,
pages: [ 1, 2, 3, 4 ]
}
API:-
const pagination = require('ap-pagination);
The response json will have this data:
1. totalItems,
2. currentPage,
3. pageSize,
4. totalPages,
5. startPage,
6. endPage,
7. startIndex,
8. endIndex,
9. pages
totalItems:- This is the total length of your array or dataset.
currentPage:- This is your current page index.
pageSize:- This is your total page size(Decides number of entries in perticular page). Default pageSize is provide 5.
totalPages:- This is total number of pages.
startPage:- This is your starting page.
endPage:- This is your ending page.
startIndex:- This is your starting index of paging.
startIndex:- This is your ending index of paging.
pages:- This is your total pages array.
**see detailed example at :- Medium Article