runebook · rune
runebook · rune
No capabilities requested.
manifest: sha256:f752cee3d20e630edb425c33e4f31a76730b0e2206af79c08e105e129ffc4231
rune add @rune/pagination@0.1.1Paginate an in-memory array for chat output, menus, or an API response.
rune add @rune/pagination
import { paginate, numberedLines } from "@rune/pagination";
const players = ["Alex", "Blake", "Casey", "Drew"];
const page = paginate(players, { page: 2, pageSize: 2 });
const lines = numberedLines(page);
// ["3. Casey", "4. Drew"]
paginate(items, { page, pageSize }) returns the selected items,
page, pageSize, total, pages, offset, previous, and next.
Defaults are page 1 and ten items per page. Integer pages clamp to the
available range. Empty arrays have one empty page. previous and next
are null at the edges.
numberedLines(page, render?) formats rows with their one-based position
in the full array. The optional renderer receives the item and its number.
Sort a copy of the input first if you need stable ordering between requests.