MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / paginate

Function paginate

packages/core/execution/src/tool-invoker.ts:398–410  ·  view source on GitHub ↗
(all: readonly T[], offset: number, limit: number)

Source from the content-addressed store, hash-verified

396};
397
398const paginate = <T>(all: readonly T[], offset: number, limit: number): PagedResult<T> => {
399 const total = all.length;
400 const start = Math.min(Math.max(offset, 0), total);
401 const items = all.slice(start, start + limit);
402 const consumed = start + items.length;
403 const hasMore = consumed < total;
404 return {
405 items,
406 total,
407 hasMore,
408 nextOffset: hasMore ? consumed : null,
409 };
410};
411
412/** What `searchTools` ranks over — the sandbox-callable path plus the v2
413 * identity fields a query can match against. */

Callers 1

tool-invoker.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected