Install this version
v0.1.1rune add @rune/pagination@0.1.1Manifest hash sha256:f752cee3d20e630edb425c33e4f31a76730b0e2206af79c08e105e129ffc4231
runebook · rune
Deterministic pagination and numbered list formatting for menus and commands.
Library Rune. Boilerplate code consumed by other Runes — the host never loads it directly. Install it as a dependency of your own Rune and import from it.
rune add @rune/pagination@0.1.1Manifest hash sha256:f752cee3d20e630edb425c33e4f31a76730b0e2206af79c08e105e129ffc4231
The author declares these capabilities as a guide. Rune scripts run with server access.
No capabilities declared by the author. Rune scripts run with server access.
Paginate 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.