pagination-calculator
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

pagination-calculator

Installation

npm install pagination-calculator

Note: the package includes typings for Typescript

Usage

import { paginationCalculator } from "pagination-calculator";
 
const result = paginationCalculator(options);

Options

interface PageCalculatorOptions {
    total: number;                // total number of items
    current?: number;             // current page
    pageSize?: number;            // number of items per page
    pageLimit?: number;           // number of pages in array
}

Result

interface PageInformation {
    total: number;                // total number of items
    current: number;              // current page
    pageCount: number;            // total number of pages
    pages: (number | "...")[];    // array of page numbers
    next: number | false;         // next page or false if end
    previous: number | false;     // previous page or false if first
    showingStart: number;         // index of first item showing on current page
    showingEnd: number;           // index of last item showing on current page
}

Readme

Keywords

Package Sidebar

Install

npm i pagination-calculator

Weekly Downloads

224

Version

1.0.0

License

MIT

Unpacked Size

29.2 kB

Total Files

13

Last publish

Collaborators

  • hisuwh