Documentation

Mistake on this page? Email us

Paginator

Type parameters

Hierarchy

  • Paginator

Implements

  • AsyncIterableIterator<T>

Index

Constructors

constructor

  • new Paginator(fetchPage: function, options?: U): Paginator
  • Create a new instance of a Paginator

    Parameters

    • fetchPage: function

      the function to fetch each page

        • (options: U): Promise<Page<T>>
        • Parameters

          • options: U

          Returns Promise<Page<T>>

    • Optional options: U

      the listOptions that are passed to every fetchPage call

    Returns Paginator

Properties

fetchPageFunction

fetchPageFunction: function

The function that returns each page

Type declaration

    • (options: U): Promise<Page<T>>
    • Parameters

      • options: U

      Returns Promise<Page<T>>

listOptions

listOptions: U

The list options to pass to all api calls during pagination

maxResults

maxResults: number

The maximum number of results to receive

pageSize

pageSize: number

The size of each page

Accessors

afters

afters:

An array of cached after values

currentPage

currentPage:

The current page

currentPageAfter

currentPageAfter:

The after value of the current page (id of the last item)

currentPageIndex

currentPageIndex:

The index of the current page (0 indexed)

currentTotalCount

currentTotalCount:

totalPages

totalPages:

The total number of possible pages, calculated using mazResults and pageSize

Methods

__@asyncIterator

  • __@asyncIterator(): AsyncIterableIterator<T>
  • Returns AsyncIterableIterator<T>

all

  • all(): Promise<Array<T>>
  • Get all possible items Note that this should only be used with a small value for maxResults

    Returns Promise<Array<T>>

first

  • first(): Promise<T>
  • Get the first item in the list

    Returns Promise<T>

goToPage

  • goToPage(number: number): Promise<Page<T>>
  • Go to a specific page

    Parameters

    • number: number

      the page number

    Returns Promise<Page<T>>

hasNextPage

  • hasNextPage(): boolean
  • Return true if the next page is available

    Returns boolean

next

  • next(): Promise<IteratorResult<T>>
  • Get the next item with the iterator.

    Returns Promise<IteratorResult<T>>

nextPage

  • nextPage(): Promise<Page<T>>
  • Get the next page

    Returns Promise<Page<T>>

previousPage

  • previousPage(): Promise<Page<T>>
  • Get the previous page

    Returns Promise<Page<T>>

reset

  • reset(): void
  • Reset the Paginator Removes all cahced items and resets all indexes

    Returns void

return

  • return(value?: any): Promise<IteratorResult<T>>
  • Parameters

    • Optional value: any

    Returns Promise<IteratorResult<T>>

throw

  • throw(e?: any): Promise<IteratorResult<T>>
  • Parameters

    • Optional e: any

    Returns Promise<IteratorResult<T>>

totalCount

  • totalCount(): Promise<number>
  • Get the number of items to be returned

    Returns Promise<number>