InferredPaginator

Source
import { InferredPaginator } from "@prestojs/util";
InferredPaginator<InferredPaginatorT = CursorPaginator|PageNumberPaginator|LimitOffsetPaginator>

Examples

Paginate manually

Use with usePaginator & paginationMiddleware

Store pagination state in the URL.

API

Constructor

new InferredPaginator(currentStatePair,internalStatePair)
Source

Arguments:

ArgumentTypeDescription
*currentStatePairany
*internalStatePairany

Methods

first()
Source
Returns:void
firstState()
Source
Returns:null|
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
|
An object with these properties:
PropertyTypeDescription
limitnumber|string
offsetnumber|string
|
An object with these properties:
PropertyTypeDescription
pagestring|number
pageSizestring|number
getRequestInit(currentInit)
Source

Arguments:

ArgumentTypeDescription
*currentInitany
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
last()
Source
Returns:void
lastState()
Source
Returns:null|
An object with these properties:
PropertyTypeDescription
limitnumber|string
offsetnumber|string
|
An object with these properties:
PropertyTypeDescription
pagestring|number
pageSizestring|number
limitState(limit)
Source

Arguments:

ArgumentTypeDescription
*limitnull|number
Returns:null|
An object with these properties:
PropertyTypeDescription
limitnumber|string
offsetnumber|string
next()
Source
Returns:void
nextState()
Source
Returns:null|
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
|
An object with these properties:
PropertyTypeDescription
limitnumber|string
offsetnumber|string
|
An object with these properties:
PropertyTypeDescription
pagestring|number
pageSizestring|number
offsetState(offset)
Source

Arguments:

ArgumentTypeDescription
*offsetnull|number
Returns:null|
An object with these properties:
PropertyTypeDescription
limitnumber|string
offsetnumber|string
pageSizeState(pageSize)
Source

Arguments:

ArgumentTypeDescription
*pageSizenull|number
Returns:null|
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
|
An object with these properties:
PropertyTypeDescription
pagestring|number
pageSizestring|number
pageState(page)
Source

Arguments:

ArgumentTypeDescription
*pagenumber
Returns:null|
An object with these properties:
PropertyTypeDescription
pagestring|number
pageSizestring|number
previous()
Source
Returns:void
previousState()
Source
Returns:null|
An object with these properties:
PropertyTypeDescription
cursorstring
pageSizenumber
|
An object with these properties:
PropertyTypeDescription
limitnumber|string
offsetnumber|string
|
An object with these properties:
PropertyTypeDescription
pagestring|number
pageSizestring|number
replaceStateControllers(props,props)
Source

Arguments:

ArgumentTypeDescription
*props[State, ]
*props[State, ]
Returns:void
setCurrentState(nextValue)
Source

Arguments:

ArgumentTypeDescription
*nextValueObject
Returns:void
setInternalState(set)
Source

Arguments:

ArgumentTypeDescription
*setObject
Returns:void
setLimit(limit)
Source

Arguments:

ArgumentTypeDescription
*limitnull|number
Returns:void
setOffset(offset)
Source

Arguments:

ArgumentTypeDescription
*offsetnull|number
Returns:void
setPage(page)
Source

Arguments:

ArgumentTypeDescription
*pagenumber
Returns:void
setPageSize(pageSize)
Source

Arguments:

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

Arguments:

ArgumentTypeDescription
*responseRecord
Returns:void

Properties

__paginator

Source
InferredPaginatorT

currentState

Source
Object

cursor

Source
null|string

internalState

Source
An object with these properties:
PropertyTypeDescription
paginatorClassany
responseIsSetboolean
...any
Any properties from Object

limit

Source
null|number

nextCursor

Source
null|string

offset

Source
null|number

page

Source
null|number

pageSize

Source
null|number

paginator

Source
undefined|InferredPaginatorT

previousCursor

Source
null|string

responseIsSet

Source
boolean

total

Source
null|number

totalPages

Source
null|number

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