array-paginate

1.0.2 • Public • Published

Array Paginate (array-paginate)

Array paginate is a library that takes in an array and paginate it to suit the needs of users.

Installation

Use the package manager [npm] to install array-paginate.

npm install array-paginate

Arguments

arrayPaginate(array, page, limit)
argument type default description
array Array undefined The array of items that is to be paginated
page Number 1 The page number to return from the pagination
limit Number 10 The number of items to be returned for each page

Usage

 
var arrayPaginate = require('array-paginate');
const array = ["first","second","third","fourth", "fifth"]
const paginatedItems = arrayPaginate(array, 1, 3);
 
console.log(paginatedItems);
//Returns
/*
{
    docs: ["first","second","third"],
    currentPage: 1,
    perPage: 3,
    total: 5,
    totalPages: 2,
    hasNextPage: true,
    hasPrevPage: false
}
*/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Package Sidebar

Install

npm i array-paginate

Weekly Downloads

7

Version

1.0.2

License

MIT

Unpacked Size

2.4 kB

Total Files

3

Last publish

Collaborators

  • mkhstar