to Offset Limit
Converts backward pagination arguments to offset/limit.
- getLast determines the page size (defaults to
defaultPageSize). - getBefore cursor encodes the index of the first item on the next page; the offset and limit are computed to return the last items ending just before that position, clamped so the window never extends before index 0.
- If
beforeis absent, a negative offset equal to-pageSizeis returned, signalling fromList to resolve from the tail of the full list. Prefer toOffsetLimit with the total count when available.
Converts backward pagination arguments to offset/limit when the total count is known.
When getBefore is absent, this computes the offset as max(0, totalCount -
last) to return the last N items from the dataset, avoiding the negative-offset signal used by toOffsetLimit. When before is present, totalCount is ignored and this delegates to toOffsetLimit.
Parameters
total Count
total number of items in the full dataset
default Page Size
default number of items when last not specified