@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
54 lines • 2.22 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import Guard from "../../guard";
import { QueryResultPagingManager } from "./query-result-paging-manager";
export class SkipTakeIteratorBase {
constructor(param) {
if (typeof param === "number") {
Guard.greaterThan(param, 0);
this._pageSize = param;
}
else {
Guard.notNullOrUndefined(param);
this._pageSize = QueryResultPagingManager.getIterationPageSize(param);
this.current = param;
}
}
canMoveNext() {
return QueryResultPagingManager.canMoveNext(this.current);
}
canMovePrevious() {
return QueryResultPagingManager.canMovePrevious(this.current);
}
moveNextAsync() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.canMoveNext()) {
return false;
}
const offset = QueryResultPagingManager.getOffsetNextPage(this.current);
this.current = yield this.getResultAsync(offset, this._pageSize);
return true;
});
}
movePreviousAsync() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.canMovePrevious()) {
return false;
}
const offset = QueryResultPagingManager.getOffsetPreviousPage(this.current);
this.current = yield this.getResultAsync(offset, this._pageSize);
return true;
});
}
reset() {
this.current = null;
}
}
//# sourceMappingURL=skip-take-iterator-base.js.map