1.0.2 • Published 5 years ago

array-paginate v1.0.2

Weekly downloads
77
License
MIT
Repository
-
Last release
5 years ago

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)
argumenttypedefaultdescription
arrayArrayundefinedThe array of items that is to be paginated
pageNumber1The page number to return from the pagination
limitNumber10The 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