Skip to content

intenter/simple-pager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-pager

simple-pager is the small and simple pager library for node. It doesn't do any rendering instead it generates data model you can use in any way in your with your template engine or with any other tools.

Installation

npm install simple-pager

Usage

var pager = require('simple-pager');
var pagesModel = pager.getPagesModel(4, 10);

The pagesModel will look like this:

[
  { page: 3 },
  { page: 4, current: true },
  { page: 5 }
]

The first page number is 1. Zero page is considered to be out of the valid pages range.

In fact getPagesModel is the only method exposed by the module:

  getPagesModel(currentPage, totalPages [, options])

If you don't pass any options by default this method generates a list with the current page and couple of surrounding pages. The first, the last and current page will be marked by the corresponding boolean property. Here is the full set of the available options with default values:

{
  surroundWith: 1, 
  outputFirst: false, 
  outputLast: false
}
  • surroundWith - number of pages to output before and after the current
  • outputFirst - whether the first page should be present in the result array
  • outputLast - whether the last page should be present in the result array

About

simple paging module for node.js

Resources

Stars

Watchers

Forks

Packages

No packages published