Documentation

Mistake on this page? Email us

Paginator Iterator-like object over an entire result set of a truncated/paginated API operation (for instance, listConnectedDevices).

Type parameters

  • T

    Entity to paginate over

  • U: ListOptions

    ListOptions class for paginator to use

Hierarchy

  • Paginator

Implements

  • AsyncIterableIterator<T>

Index

Constructors

constructor

  • new Paginator(getPage: function, options?: U): Paginator
  • Constructor

    Parameters

    • getPage: function

      Method returning a page of results (ListResponse)

    • Optional options: U

      List options

    Returns Paginator

Properties

maxResults

maxResults: number

Methods

__@asyncIterator

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

all

  • all(): Promise<Array<T>>
  • Gets an array of all the elements of the collection. Note: This requires browsing the whole collection and therefore can be expensive. Moreover, all elements are stored in memory and hence, be careful when dealing with big collections.

    Returns Promise<Array<T>>

executeForAll

  • executeForAll(execute: function): Promise<void>
  • Executes a function on all the elements of the collection.

    Parameters

    • execute: function

      method to execute on the elements Note: This requires browsing the whole collection and therefore can be expensive.

        • (element: T): void
        • Parameters

          • element: T

          Returns void

    Returns Promise<void>

first

  • first(): Promise<T>
  • Returns the first item from the query, or null if there are no results.

    Returns Promise<T>

hasNext

  • hasNext(): boolean
  • Checks whether there is a next element in the collection.

    Returns boolean

next

  • next(): Promise<IteratorResult<T>>
  • Returns Promise<IteratorResult<T>>

pageSize

  • pageSize(): number
  • Gets page size.

    Returns number

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>
  • Gets collection total count (Approximate number of results according to the API).

    Returns Promise<number>