Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

giant-piano

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

giant-piano

Minimal Javascript pagination utility

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

giant-piano

Build Status NPM Version

Description

giant-piano is a small Javascript pagination utility. All it does is providing you the logic to render a pagination component in your app.

Features

Usage

npm install giant-piano --save

Then, in your app:

var createPagination = require('giant-piano');

/* 
  `itemsPerPage` and `maxPages` are normally static,
  so you should call `createPagination` only once.
*/
var paginate = createPagination({ itemsPerPage: 10, maxPages: 5 });

/*
  Then, call `paginate` with the current page number 
  and the total amount of items.
*/
console.log(paginate({ currentPage: 5, totalItems: 63 }));
/* {
     showFirst: true,
     showPrev: true,
     pages: [3, 4, 5, 6, 7],
     showNext: true,
     showLast: false,
     lastPage: 7
   }
*/

console.log(paginate({ currentPage: 2, totalItems: 34 }));
/* {
     showFirst: false,
     showPrev: true,
     pages: [1, 2, 3, 4],
     showNext: true,
     showLast: false,
     lastPage: 4
   }
*/

console.log(paginate({ currentPage: 1, totalItems: 1234 }));
/* {
     showFirst: false,
     showPrev: false,
     pages: [1, 2, 3, 4, 5],
     showNext: true,
     showLast: true,
     lastPage: 124
   }
*/

Run demo locally

npm start

License

MIT

Keywords

FAQs

Package last updated on 23 Mar 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc