🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

paginator-walker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paginator-walker

Simple pages-numbers array generator

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Paginator walker

Simple pages-numbers array generator.

Generates what pages numbers you should show, based on current page position and total pages, with custom threshold and number of pages to show.

With the default config params, from page 1 to page 4 generates [1, 2, 3, 4, 5], for page 5 it will walk and show [2, 3, 4, 5, 6]; if custom threshold config is in use, page 4 will start the walk [2, 3, 4, 5, 6] (threshold with value of 2).

Usage

const walker = require('pages-walker')
const currentPage = 1 // dynamic value from user
const totalPages = 10 // total pages from pagination
const pages = walker(currentPage, totalPages)

// pages -> [1,2,3,4,5] - 5 pages by default

Params

  • currentPage:1: Current page to calculate prev/next pages.
  • totalPages:5: Total pages from your pagination results.
  • Configuration:{ threshold: 1, showPages: 5 }: Configuration object for threshold and pages to generate.

Keywords

pagination

FAQs

Package last updated on 28 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts