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

Function paginate

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

Source from the content-addressed store, hash-verified

463};
464
465const paginate = <T>(all: readonly T[], offset: number, limit: number): PagedResult<T> => {
466 const total = all.length;
467 const start = Math.min(Math.max(offset, 0), total);
468 const items = all.slice(start, start + limit);
469 const consumed = start + items.length;
470 const hasMore = consumed < total;
471 return {
472 items,
473 total,
474 hasMore,
475 nextOffset: hasMore ? consumed : null,
476 };
477};
478
479/** What `searchTools` ranks over — the sandbox-callable path plus the v2
480 * identity fields a query can match against. */

Callers 1

tool-invoker.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected