@sysafarila/js-paginate
v0.0.14
Published
An agnostic pagination package for JavaScript.
Downloads
183
Maintainers
Readme
JS-Paginate
An agnostic pagination package for JavaScript.
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/[email protected]/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/[email protected]/+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.