An agnostic pagination package for JavaScript.
Run this command below on your terminal
npm i @sysafarila/js-paginate
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
|
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>
import { paginate } from "@sysafarila/js-paginate";
const result = paginate({
current_page: 12,
length: 9,
pages: 20,
});
console.log(result);
const { paginate } = require("@sysafarila/js-paginate");
const result = paginate({
current_page: 12,
length: 9,
pages: 20,
});
console.log(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.