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

Function paginate

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

Source from the content-addressed store, hash-verified

442};
443
444const paginate = <T>(all: readonly T[], offset: number, limit: number): PagedResult<T> => {
445 const total = all.length;
446 const start = Math.min(Math.max(offset, 0), total);
447 const items = all.slice(start, start + limit);
448 const consumed = start + items.length;
449 const hasMore = consumed < total;
450 return {
451 items,
452 total,
453 hasMore,
454 nextOffset: hasMore ? consumed : null,
455 };
456};
457
458/** What `searchTools` ranks over — the sandbox-callable path plus the v2
459 * identity fields a query can match against. */

Callers 1

tool-invoker.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected