Git Product home page Git Product logo

page-pagination's Introduction

It's typescript version of paginator

Overview

When developing any kind of application that involves fetching an arbitrary number of elements from somewhere, you'll almost always want some form of pagination. It's impossible to tell in advance how the rest of the application will work, so a generic module that does -only- the pagination algorithm is useful. Enter Paginator.

Usage

Also see the documentation.

var Paginator = require("paginator");

// Arguments are `per_page` and `length`. `per_page` changes the number of
// results per page, `length` changes the number of links displayed.
var paginator = new Paginator(30, 7);

// Arguments are `total_results` and `current_page`. I hope these are self
// explanatory.
var pagination_info = paginator.build(10000, 50);

// The returned object will look something like this.
{
  total_pages: 334,
  current_page: 50,
  first_page: 46,
  last_page: 53,
  previous_page: 49,
  next_page: 51,
  has_previous_page: true,
  has_next_page: true,
  total_results: 10000,
  results: 30,
  first_result: 1470,
  last_result: 1499,
}

License

Licensed under an MIT license.

page-pagination's People

Contributors

twn39 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.