Documentation / @zerotal/flow / index / paginate
Function: paginate()
paginate<
T>(items,page?,perPage?):Paginator<T>
Defined in: flow/src/pagination.ts:106
Paginate an in-memory array — the array counterpart to the ORM's
.paginate(perPage, page). Use this for filtered/derived data you already
hold in memory (e.g. inside render() or onMount()); for database queries
prefer the query builder's paginator.
page is clamped into [1, lastPage] and perPage is floored to at least 1,
so out-of-range input never throws.
Type Parameters
T
T
Element type of items.
Parameters
items
T[]
The full, already-in-memory collection to page over.
page?
number = 1
1-based page to return (clamped; default 1).
perPage?
number = 15
Items per page (floored to >= 1; default 15).
Returns
Paginator<T>
A Paginator for the requested page.
Example
const results = posts.filter((p) => p.published);
const page = paginate(results, this.page, 10);
for (const post of page.data) { ... }