vinmonopolet-ts
Version:
Extracts information on products, categories and stores from Vinmonopolet
25 lines (24 loc) • 859 B
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Pagination {
constructor(paging, options, fetcher) {
this.currentPage = paging.currentPage;
this.pageSize = paging.pageSize;
this.totalPages = paging.totalPages;
this.totalResults = paging.totalResults;
this.hasNext = paging.currentPage < this.totalPages;
this.hasPrevious = paging.currentPage > 0;
this.sort = paging.sort;
this.fetcher = fetcher;
this.options = options;
}
next() {
return this.fetcher(Object.assign({}, this.options, { page: this.options.page + 1 }));
}
previous() {
return this.fetcher(Object.assign({}, this.options, {
page: Math.max(0, this.options.page - 1),
}));
}
}
exports.default = Pagination;