![GitHub license](https://img.shields.io/github/license/AndreiLucaci/simple-pagination)
Simple pagination module for arrays.
Usage
1. Instalation
npm install arrpag --save
yarn add arrpag
bower install arrpag --save
2. Return object
The return object
is an object of this format:
export interface IPaginationResult {
totalResults: number;
results: any[];
pages: number;
currentPage: number;
prevPage: number;
nextPage: number;
perPage: number;
totalCurrentResults: number;
}
3. Usage
Javascript
const paginator = require("arrpag");
const arr = [1, 2, 3, 4, 5];
const paginationResult = paginator.paginate(arr, 2, 3);
Typescript
import { paginate } from "arrapg";
const arr = [1, 2, 3, 4, 5];
const paginationResult = paginate(arr, 2, 3);
AMD
define(function(require, exports, module) {
var paginate = require("arrpag");
});
For the previous example the output should be:
{
totalResults: 5,
results: [ 4, 5 ],
pages: 2,
currentPage: 2,
prevPage: 1,
nextPage: 2,
perPage: 3,
totalCurrentResults: 2
}
4. Test
npm run test