CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 22:55:12 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=81b78ee7d7a39f8b6bf740a318add99b17c5a55eb0c65ca101a0166df244097da%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22t9mRa3qBBDQz8srGWkC_OTcEZOT1NzyV%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d1f19349adc1cc-BLR
Virtual Pagination - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Pagination
- *
- * Handle page results and meta data from a list of items
- *
- *
- * @use ```
- * pagination = new Pagination()
- * pagination.setLimit(10)
- * pagination.setItems(items)
- * pagination.getResults(1)
- * pagination.getMeta()
- * ```
- */
- export class Pagination {
- /**
- * @type {any[]}
- */
- items = []
- /**
- * @type {number}
- */
- limit
- /**
- * @type {{totalItems: number, totalPage: number, limit: number, page: number}}
- */
- meta
- constructor({ limit = 10, items = [] } = {}) {
- this.items = items
- this.limit = limit
- this.meta = {
- totalPage: 1,
- page: 1,
- totalItems: items.length,
- limit,
- }
- }
- setItems(value) {
- this.items = value
- const totalItems = this.items.length
- this.setMeta({ totalItems })
- }
- getItems() {
- return this.items
- }
- setLimit(value) {
- this.limit = value
- }
- getLimit() {
- return this.limit
- }
- getMeta() {
- return { ...this.meta }
- }
- setMeta({ page = 1 }) {
- const totalPage = this.computeMaxPage()
- this.meta = {
- totalPage,
- page,
- totalItems: this.items.length,
- limit: this.limit,
- }
- }
- getResults(page) {
- this.setMeta({ page: page > 0 ? page : 1 })
- const index = this.limit * (page - 1)
- return [...this.items].splice(index, this.limit)
- }
- computeMaxPage() {
- const divided = this.items.length / this.limit
- const isNaN = divided !== divided
- return isNaN || !divided ? 1 : Math.ceil(divided)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ J
JavaScript | 1 sec ago | 0.25 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 1 sec ago | 0.10 KB
-
📝 Crypto Swap Glitch ✅ Working
JavaScript | 6 sec ago | 0.24 KB
-
⭐✅ Swapzone Glitch ✅ Working ⭐⭐ Q
JavaScript | 10 sec ago | 0.25 KB
-
⭐⭐⭐Crypto Accounts⭐⭐
Java | 12 sec ago | 0.10 KB
-
📝 EASY MONEY GUIDE ✅ Working
JavaScript | 15 sec ago | 0.24 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ 3
JavaScript | 18 sec ago | 0.25 KB
-
📌 Swapzone +37% glitch ⭐ R
JavaScript | 21 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand