ap-pagination

It is provide paging which is use in data tables and showing pagination

Usage no npm install needed!

<script type="module">
  import apPagination from 'https://cdn.skypack.dev/ap-pagination';
</script>

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
  1. totalItems:- This is the total length of your array or dataset.

  2. currentPage:- This is your current page index.

  3. pageSize:- This is your total page size(Decides number of entries in perticular page). Default pageSize is provide 5.

  4. totalPages:- This is total number of pages.

  5. startPage:- This is your starting page.

  6. endPage:- This is your ending page.

  7. startIndex:- This is your starting index of paging.

  8. startIndex:- This is your ending index of paging.

  9. pages:- This is your total pages array.

**see detailed example at :- Medium Article