@smallstack/api-shared
Advanced tools
Comparing version 1.122.0-rc.1 to 1.122.0-rc.2
{ | ||
"name": "@smallstack/api-shared", | ||
"version": "1.122.0-rc.1", | ||
"version": "1.122.0-rc.2", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "tslib": "2.5.3" |
@@ -15,1 +15,2 @@ import { PageRequest } from "./page-request"; | ||
export declare function isPage(page: any): page is Page<any>; | ||
export declare function loadAllPages<T>(apiCallFn: (page: number) => Promise<Page<T>>): Promise<T[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPage = exports.createPageFrom = exports.convertPageElements = exports.MAX_PAGE_SIZE = exports.DEFAULT_PAGE_SIZE = void 0; | ||
exports.loadAllPages = exports.isPage = exports.createPageFrom = exports.convertPageElements = exports.MAX_PAGE_SIZE = exports.DEFAULT_PAGE_SIZE = void 0; | ||
const tslib_1 = require("tslib"); | ||
// Pagination | ||
@@ -52,2 +53,17 @@ exports.DEFAULT_PAGE_SIZE = 25; | ||
exports.isPage = isPage; | ||
function loadAllPages(apiCallFn) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
let page = 1; | ||
let responsePage; | ||
const models = []; | ||
do { | ||
responsePage = yield apiCallFn(page); | ||
if ((responsePage === null || responsePage === void 0 ? void 0 : responsePage.elements) instanceof Array) | ||
models.push(...responsePage.elements); | ||
page++; | ||
} while (responsePage.hasNext); | ||
return models; | ||
}); | ||
} | ||
exports.loadAllPages = loadAllPages; | ||
//# sourceMappingURL=page.js.map |
Sorry, the diff of this file is not supported yet
11495
179