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

Function paginate

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

Source from the content-addressed store, hash-verified

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

Callers 1

tool-invoker.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected