New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pypagination

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pypagination

A small library to paginate through json objects

  • 0.0.3
  • PyPI
  • Socket score

Maintainers
1

USAGE

To import:

from pypagination import paginate

Call the paginate function:

paginate(150):

{ 
    totalItems: 150,
    currentPage: 1,
    pageSize: 10,
    totalPages: 15,
    startPage: 1,
    endPage: 10,
    startIndex: 0,
    endIndex: 9,
    pages: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] 
}

paginate(150, 7): totalItems: 150, currentPage: 7, pageSize: 15

{ 
    totalItems: 150,
    currentPage: 7,
    pageSize: 10,
    totalPages: 15,
    startPage: 2,
    endPage: 11,
    startIndex: 60,
    endIndex: 69,
    pages: [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] 
}

paginate(150, 7, 15, 5) totalItems: 150, currentPage: 7, pageSize: 15, maxPages: 5

{ 
    totalItems: 150,
    currentPage: 7,
    pageSize: 15,
    totalPages: 10,
    startPage: 5,
    endPage: 9,
    startIndex: 90,
    endIndex: 104,
    pages: [ 5, 6, 7, 8, 9 ] 
}

BRIEF

The paginate function accepts the following parameters:

  1. totalItems (required) - the total number of items to be paged
  2. currentPage (optional) - the current active page, defaults to the first page
  3. pageSize (optional) - the number of items per page, defaults to 10
  4. maxPages (optional) - the maximum number of page navigation links to display, defaults to 10

The output of the paginate function is an object containing all the information needed to display the current page of items in the view and the page navigation links.

FAQs


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