MCPcopy Create free account
hub / github.com/EvoMap/evolver / paginate

Function paginate

src/webui/observer/jsonl.js:47–61  ·  view source on GitHub ↗
(items, query = {})

Source from the content-addressed store, hash-verified

45}
46
47function paginate(items, query = {}) {
48 const limit = Math.min(toPositiveInt(query.limit, 50), 200);
49 const offset = Math.max(0, toPositiveInt(query.offset || query.cursor, 0));
50 const data = items.slice(offset, offset + limit);
51 const nextOffset = offset + data.length;
52 return {
53 data,
54 pagination: {
55 limit,
56 offset,
57 totalItems: items.length,
58 nextCursor: nextOffset < items.length ? String(nextOffset) : null,
59 },
60 };
61}
62
63function toPositiveInt(value, fallback) {
64 const n = Number(value);

Callers 7

listGenesFunction · 0.85
listCapsulesFunction · 0.85
listEventsFunction · 0.85
listCandidatesFunction · 0.85
listAssetCallsFunction · 0.85
getInteractionsFunction · 0.85
listRunsFunction · 0.85

Calls 1

toPositiveIntFunction · 0.85

Tested by

no test coverage detected