CursorPaginator

Source
import { CursorPaginator } from "@prestojs/util";
Hierarchy
  • Paginator<,>
  • CursorPaginator

Examples

Paginate manually

Use with usePaginator & paginationMiddleware

Store pagination state in the URL.

API

Constructor

new CursorPaginator(?currentStatePair,?internalStatePair)
Source

Arguments:

ArgumentTypeDescription
currentStatePairnull|[State, ]
internalStatePairnull|[State, ]

Methods

first()
Source
Returns:void
firstState()
Source
Returns:
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
getRequestInit(props)
Source

Arguments:

ArgumentTypeDescription
*
props
An object with the properties below
props.bodynull|BodyInit
props.cacheRequestCache
props.credentialsRequestCredentials
props.headersHeadersInit|Record
props.integritystring
props.keepaliveboolean
props.methodstring
props.modeRequestMode
props.queryRecord
props.redirectRequestRedirect
props.referrerstring
props.referrerPolicyReferrerPolicy
props.signalnull|AbortSignal
props.urlArgsRecord
props.windownull
Returns:
An object with these properties:
PropertyTypeDescription
bodynull|BodyInit
cacheRequestCache
credentialsRequestCredentials
headersHeadersInit|Record
integritystring
keepaliveboolean
methodstring
modeRequestMode
queryRecord
redirectRequestRedirect
referrerstring
referrerPolicyReferrerPolicy
signalnull|AbortSignal
urlArgsRecord
windownull
hasNextPage()
Source
Returns:boolean
hasPreviousPage()
Source
Returns:boolean
next()
Source
Returns:void
nextState()
Source
Returns:null|
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
pageSizeState(pageSize)
Source

Arguments:

ArgumentTypeDescription
*pageSizenull|number
Returns:
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
previous()
Source
Returns:void
previousState()
Source
Returns:null|
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
replaceStateControllers(currentStatePair,internalStatePair)
Source

Arguments:

ArgumentTypeDescription
*currentStatePair[State, ]
*internalStatePair[State, ]
Returns:void
setCurrentState(set)
Source

Arguments:

ArgumentTypeDescription
*set
Returns:void
setInternalState(set)
Source

Arguments:

ArgumentTypeDescription
*set
Returns:void
setPageSize(pageSize)
Source

Arguments:

ArgumentTypeDescription
*pageSizenull|number
Returns:void
setResponse(props)
Source

Arguments:

ArgumentTypeDescription
*props
Returns:void

Properties

currentState

Source
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber

cursor

Source
null|string

internalState

Source
An object with these properties:
PropertyTypeDescription
nextCursorstring|null
previousCursorstring|null
responseIsSetboolean

nextCursor

Source
null|string

pageSize

Source
null|number

previousCursor

Source
null|string

responseIsSet

Source
boolean

Static Methods

getPaginationState(requestDetails)
Source

Arguments:

ArgumentTypeDescription
*
requestDetails
An object with the properties below
requestDetails.decodedBodyany
requestDetails.queryRecord
requestDetails.responseResponse
*requestDetails.urlstring
requestDetails.urlArgsRecord
Returns:false|Record