UNPKG

coloquent-test2

Version:

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

42 lines 2 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var PaginationSpec_1 = require("./PaginationSpec"); var QueryParam_1 = require("./../QueryParam"); var PageBasedPaginationSpec = /** @class */ (function (_super) { __extends(PageBasedPaginationSpec, _super); function PageBasedPaginationSpec(pageNumberParamName, pageSizeParamName, pageLimit) { var _this = _super.call(this) || this; _this.queryParams = []; _this.pageNumberParamName = pageNumberParamName; _this.pageSizeParamName = pageSizeParamName; _this.pageLimit = pageLimit; return _this; } PageBasedPaginationSpec.prototype.getPaginationParameters = function () { 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; }; PageBasedPaginationSpec.prototype.setPage = function (page) { page = Math.max(page, 1); this.pageNumber = page; }; PageBasedPaginationSpec.prototype.setPageLimit = function (pageLimit) { this.pageLimit = pageLimit; }; return PageBasedPaginationSpec; }(PaginationSpec_1.PaginationSpec)); exports.PageBasedPaginationSpec = PageBasedPaginationSpec; //# sourceMappingURL=PageBasedPaginationSpec.js.map