Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord.

Overview
Pagination Manager Logo

Pagination Manager

  • Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord.
  • Lightweight module, ES6 and CommonJS compatible.
  • Package developed by tnfAngel#6557

Usage

CommonJS

const { PaginationBuilder, PaginationManager } = require('pagination-manager');

const pagesBuilder = new PaginationBuilder()
    .addPages([{ hi: 'this is a page' }, { hi: 'this is another page'}])
    .setOptions({ infinitePages: true });

const paginationManager = new PaginationManager(pagesBuilder);

console.log(
    paginationManager.getCurrentPage()
); // { hi: 'this is a page' }

console.log(
    paginationManager.next()
); // { hi: 'this is another page'}

console.log(
    paginationManager.getCurrentPage()
); // { hi: 'this is another page'}

TypeScript

import { PaginationBuilder, PaginationManager } from 'pagination-manager';

const pagesBuilder = new PaginationBuilder()
    .addPages([{ hi: 'this is a page' }, { hi: 'this is another page'}])
    .setOptions({ infinitePages: true });

const paginationManager = new PaginationManager(pagesBuilder);

console.log(
    paginationManager.getCurrentPage()
); // { hi: 'this is a page' }

console.log(
    paginationManager.next()
); // { hi: 'this is another page'}

console.log(
    paginationManager.getCurrentPage()
); // { hi: 'this is another page'}

Documentation

Pagination Manager Classes

  • PaginationBuilder | .PaginationBuilder() -> PaginationBuilder

Builder class for setup the pagination manager and configure the options.

const paginationBuilder = new PaginationBuilder()
    .addPages([Page1, Page2, Page3]) // Adds multiple pages to the PaginationBuilder.
    .addPage(Page4) // Adds a single page.
    .setPages([Page5, Page6, Page7]) //Set the pages in the array.
    .setOptions({ infinitePages: false }); // Pagination Manager options. infinitePages means if when reaching the end of pages, the current page will return to the beginning and vice versa.

const paginationManager = new PaginationManager(paginationBuilder);
  • PaginationManager | .PaginationManager(PaginationBuilder) -> PaginationManager

Main class, provide all manager methods and properties.

const paginationManager = new PaginationManager(paginationBuilder); // PaginationBuilder constructor here.

Pagination Manager Class Methods

  • GetCurrentPage | .getCurrentPage() -> CurrentPage

Returns the current active page. Default to 0.

PaginationManager.getCurrentPage();
  • GetPages | .getPages() -> Pages

Returns alls the pages passed in PaginationBuilder class.

PaginationManager.getPages();
  • Next | .next() -> Page

Sets the current page to the next page and return it.

PaginationManager.next();
  • Prev | .prev() -> Page

Sets the current page to the previous page and return it.

PaginationManager.prev();
  • First | .first() -> Page

Sets the current page to the first page and return it.

PaginationManager.first();
  • Last | .last() -> Page

Sets the current page to the last page and return it.

PaginationManager.last();
  • SetPage | .setPage(page) -> Page

Sets the current page to the page provided and return it. Pages will start with 0.

PaginationManager.setPage(0);
  • SetHumanPage | .setHumanPage(page) -> Page

Sets the current page to the page provided and return it. Same as SetPage but pages will start with 1.

PaginationManager.setHumanPage(1);
  • GetPage | .getPage(page) -> Page

Returns the page provided. Pages will start with 0.

PaginationManager.getPage(0);
  • GetHumanPage | .getHumanPage(page) -> Page

Returns the page provided. Same as GetPage but pages will start with 1.

PaginationManager.getHumanPage(1);

Pagination Manager Class Property's

  • Pages | .pages -> Page[]

Returns alls the pages passed in PaginationBuilder class.

PaginationManager.pages; // [...]
  • Options | .options -> PaginationBuilderOptions

Returns the options passed in PaginationBuilder class.

PaginationManager.options; // {...}
  • PagesSize | .pagesSize -> number

Returns the pages size starting with 0.

PaginationManager.pagesSize; // 2
  • HumanPagesSize | .humanPagesSize -> number

Returns the pages size starting with 1.

PaginationManager.humanPagesSize; // 3
  • CurrentPageIndex | .currentPageIndex -> number

Returns the current page index starting with 0.

PaginationManager.currentPageIndex; // 0
  • HumanCurrentPageIndex | .humanCurrentPageIndex -> number

Returns the current page index starting with 1.

PaginationManager.humanCurrentPageIndex; // 1
  • NextPageIndex | .nextPageIndex -> number

Returns the next page index starting with 0.

PaginationManager.nextPageIndex; // 1
  • HumanNextPageIndex | .humanNextPageIndex -> number

Returns the next page index starting with 1.

PaginationManager.humanNextPageIndex; // 2
  • PrevPageIndex | .prevPageIndex -> number

Returns the previous page index starting with 0.

PaginationManager.prevPageIndex; // 0
  • HumanPrevPageIndex | .humanPrevPageIndex -> number

Returns the previous page index starting with 1.

PaginationManager.humanPrevPageIndex; // 1
  • PageIndicator | .pageIndicator -> string

Returns an human-readable string with the human current page index and the human page size.

PaginationManager.pageIndicator; // 1/3
  • CurrentPage | .currentPage -> CurrentPage

Returns the current page element.

PaginationManager.currentPage; // {...}

Installation

If you have installation issues, join our support server.

Node Package Manager (NPM)

  1. Open: Terminal/CMD
  2. Put: npm i pagination-manager

Yarn

  1. Open: Terminal/CMD
  2. Put: yarn add pagination-manager

Pagination Banner

You might also like...

we learn the whole concept of JS including Basics like Object, Functions, Array etc. And Advance JS - Understanding DOMs, JQuery, Ajax, Prototypes etc.

JavaScript-for-Complete-Web Development. we learn the whole concept of JS including Basics like Object, Functions, Array etc. And Advance JS - Underst

Jul 22, 2022

Very tiny function that checks if an object/array/value is shaped like another, with TypeScript type refining.

@suchipi/has-shape Very tiny (~200B before minification/compression) function that checks if an object/array/value is shaped like another, with TypeSc

Aug 13, 2022

🧬 A type builder for pagination with prisma and type-graphql.

🧬 Prisma TypeGraphql Pagination Prisma TypeGraphql Pagination builds prisma pagination types for type-graphql. import { ... } from 'type-graphql'

Apr 21, 2022

Holy Qur'an Telegram Bot with pagination and audio, in Indonesian language.

Holy Qur'an Telegram Bot with pagination and audio, in Indonesian language.

quran-telegram-bot Contributions are Welcome! Demo @fio_quran_bot Run Tested on Node.js v14.x.x with NPM v6.x.x, Windows 10 and Ubuntu 18.04.6 LTS. Cr

Oct 21, 2022

A simple javascript library for pagination, compatible with Bootstrap.

A simple javascript library for pagination, compatible with Bootstrap.

Easy Pagination JS A simple library for pagination, compatible with Bootstrap. Check my website here. Demo Check this Demo here. Example Import the fi

Aug 5, 2022

A jQuery plugin for making html tables searchable and sortable with pagination

jQuery.fancyTable A jQuery plugin for making html tables searchable and sortable with pagination. Live demo See a live demo on CodePen Installation Us

Dec 19, 2022

A handler to create embedded pages with buttons for pagination.

➝ Whats that • A handler to create embedded pages with buttons for pagination. ➝ Requirements • ["Handler"] pages.js • [Example command] embed.js ➝ Us

Oct 30, 2022

URL Shortener API in NodeJS supporting pagination, sort params and lot more

URL Shortener API in NodeJS supporting pagination, sort params and lot more

node-url-shortener Built with ❤️ in NodeJS A simple URL Shortner REST API that uses shortid npm package to generate short endpoints for your long URL.

Sep 22, 2022
Owner
tnfAngel
👋 ¡Hola! Soy tnfAngel, un desarrollador Web y Android Full-Stack, Analista de Ciberseguridad y Contribuidor OSS.
tnfAngel
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A JavaScript library improving inspection of objects

Pro Inspector A JavaScript utility improving inspection of objects on Node.js. Introduction Let's suppose that we have this declaration. class Person

Reiryoku Technologies 60 Dec 30, 2022
GraphErr is an open-source error handling library for GraphQL implementations in Deno. It's a lightweight solution that provides developers with descriptive error messages, reducing ambiguity and improving debugging.

GraphErr Descriptive GraphQL error handling for Deno/Oak servers. Features Provides additional context to GraphQL's native error messaging for faster

OSLabs Beta 35 Nov 1, 2022
Superlight vanilla javascript plugin improving forms look and functionality

Superlight pure javascript form switch plugin by LCweb Give a modern look to your applications and take advantage of javascript events and public func

Luca 31 Mar 9, 2022
Meogic-tab-manager is an extensible, headless JavaScript tab manager framework.

MeogicTabManager English document MeogicTabManager是一个有可拓展性的、headless的JavaScript标签页管理框架。 MeogicTabManager旨在提供可自由组装页面框架、自定义页面组件、甚至覆盖框架自带事件响应的开发体验。 Meogi

meogic-tech 5 Oct 8, 2022
Types generator will help user to create TS types from JSON. Just paste your single object JSON the Types generator will auto-generate the interfaces for you. You can give a name for the root object

Types generator Types generator is a utility tool that will help User to create TS Interfaces from JSON. All you have to do is paste your single objec

Vineeth.TR 16 Dec 6, 2022
Simple and easy-to-use pagination library for Mongoose (Node.js)

node-paginator Simple and easy-to-use pagination library for Mongoose (Node.js) ?? Why node-paginator? Every web developer should work on pagination a

CareerDay 2 Sep 21, 2022
A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebWorker like neither of those.

Amuchina A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebW

Fabio Spampinato 9 Sep 17, 2022