summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js b/node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js
new file mode 100644
index 0000000..5f11fc7
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/builders/pagination.js
@@ -0,0 +1,51 @@
+/**
+ * Created by km on 10/5/16.
+ */
+/// The suggested maximum items to load per page.
+export const suggestedMaxPerPage = 20;
+/**
+ * Returns a single page of lookup data from a page token.
+ * @param pageToken The page token to extract the ids from.
+ * @returns An array of zero or more ids to lookup.
+ */
+export function getDataForLookup(objectGraph, pageToken) {
+ if (!pageToken || !pageToken.remainingContent) {
+ return [];
+ }
+ return pageToken.remainingContent.slice(0, pageToken.maxPerPage);
+}
+/**
+ * Returns a page token containing the ids to fetch for the next page of data.
+ * @param pageToken The page token to advance.
+ * @param count The number of items to get, or all items if not specified
+ * @returns A new page token.
+ */
+export function nextPageToken(objectGraph, pageToken, count) {
+ const nextToken = { ...pageToken };
+ if (pageToken && pageToken.remainingContent) {
+ const nextContent = nextDataRange(objectGraph, pageToken.remainingContent, pageToken.maxPerPage, count);
+ nextToken.remainingContent = nextContent;
+ }
+ return nextToken;
+}
+/**
+ * Returns a subset of the content from start to the end of the array
+ * @param ids The array of IDs from which to get the sub array
+ * @param start The starting index
+ * @param count The number of items to get, or all items if not specified
+ * @returns An array of all ids from start until the end of the array
+ */
+export function nextDataRange(objectGraph, dataArray, start, count) {
+ return dataArray.slice(start, count !== null && count !== void 0 ? count : dataArray.length);
+}
+export function createMediaPageToken(objectGraph, remaining, url, nextHref = null, pageInformation, locationTracker) {
+ return {
+ remainingContent: remaining,
+ maxPerPage: suggestedMaxPerPage,
+ highestOrdinal: 0,
+ url: url,
+ metricsPageInformation: pageInformation,
+ metricsLocationTracker: locationTracker,
+ };
+}
+//# sourceMappingURL=pagination.js.map \ No newline at end of file