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

Function paginate

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

Source from the content-addressed store, hash-verified

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

Callers 1

tool-invoker.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected