UNPKG

@maicol07/coloquent

Version:

Library for retrieving model objects from a JSON-API, with a fluent syntax inspired by Laravel Eloquent.

31 lines 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PageBasedPaginationSpec = void 0; const PaginationSpec_1 = require("./PaginationSpec"); const QueryParam_1 = require("./../QueryParam"); class PageBasedPaginationSpec extends PaginationSpec_1.PaginationSpec { constructor(pageNumberParamName, pageSizeParamName, pageLimit) { super(); this.queryParams = []; this.pageNumberParamName = pageNumberParamName; this.pageSizeParamName = pageSizeParamName; this.pageLimit = pageLimit; } getPaginationParameters() { this.queryParams = []; if (this.pageNumber !== undefined) { this.queryParams.push(new QueryParam_1.QueryParam(`${this.pageNumberParamName}`, this.pageNumber)); this.queryParams.push(new QueryParam_1.QueryParam(`${this.pageSizeParamName}`, this.pageLimit)); } return this.queryParams; } setPage(page) { page = Math.max(page, 1); this.pageNumber = page; } setPageLimit(pageLimit) { this.pageLimit = pageLimit; } } exports.PageBasedPaginationSpec = PageBasedPaginationSpec; //# sourceMappingURL=PageBasedPaginationSpec.js.map