toOffsetWindow
function toOffsetWindow(input): OffsetWindow;Defined in: pagination.ts:85
Convert page or offset input into a { limit, offset } window
(page is 1-based). Cursor input is intentionally not convertible.
Never throws: bad transport numbers are clamped. Values are truncated to
integers, page/pageSize/limit to at least 1, and offset to at least 0.
The returned limit is the raw page size (no lookahead row added here).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
| PagePagination | OffsetPagination |
Returns
Section titled “Returns”Example
Section titled “Example”import { toOffsetWindow } from "@xtandard/lib/pagination";
toOffsetWindow({ type: "page", page: 3, pageSize: 20 }); // { limit: 20, offset: 40 }toOffsetWindow({ type: "offset", limit: 20, offset: 40 }); // { limit: 20, offset: 40 }toOffsetWindow({ type: "page", page: 0, pageSize: -5 }); // { limit: 1, offset: 0 }toOffsetWindow({ type: "offset", limit: 2.7, offset: -10 }); // { limit: 2, offset: 0 }