@sysafarila/js-paginate
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

JS-Paginate

An agnostic pagination package for JavaScript.

NPM License GitHub Actions Workflow Status GitHub Actions Workflow Status NPM Downloads NPM Version GitHub Release npm bundle size NPM Unpacked Size

Installation

Run this command below on your terminal

npm i @sysafarila/js-paginate

Usage

Parameter Description Required
current_page Current page or active page YES
pages Total pages (Received from Back-end) YES
length Limit generated array length YES, Optional since v0.0.12

CDN

jsDelivr https://www.jsdelivr.com/package/npm/@sysafarila/js-paginate

<script src="https://cdn.jsdelivr.net/npm/@sysafarila/js-paginate@0.0.12/dist/index.min.js"></script>
<script>
  const result = paginate({
    current_page: 12,
    length: 9,
    pages: 20,
  });

  console.log(result);
</script>

or

<script type="module">
  import { paginate } from "https://cdn.jsdelivr.net/npm/@sysafarila/js-paginate@0.0.12/+esm";

  const result = paginate({
    current_page: 12,
    length: 9,
    pages: 20,
  });

  console.log(result);
</script>

ES Module

import { paginate } from "@sysafarila/js-paginate";

const result = paginate({
  current_page: 12,
  length: 9,
  pages: 20,
});

console.log(result);

CommonJs

const { paginate } = require("@sysafarila/js-paginate");

const result = paginate({
  current_page: 12,
  length: 9,
  pages: 20,
});

console.log(result);

Result

Return value of paginate function:

[8, 9, 10, 11, 12, 13, 14, 15, 16];

Next, you have to loop this generated array to build your own UI.

Package Sidebar

Install

npm i @sysafarila/js-paginate

Weekly Downloads

2

Version

0.0.14

License

MIT

Unpacked Size

6.34 kB

Total Files

7

Last publish

Collaborators

  • sysafarila