1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
|