Class Paginator<T>

Utility to paginate data.

Type Parameters

  • T

Hierarchy

  • Paginator

Implements

  • Iterable<T>

Constructors

  • The paginator constructor.

    Returns

    Type Parameters

    Type Parameters

    • T

    Parameters

    • Optional elements: MaybeArray<T>
    • itemsPerPage: number = 10
    • wrapsAround: boolean = false

    Returns Paginator<T>

Properties

elements: T[]

All the items passed to the paginator.

internalCurrentPage: number = 1

The internal current page. This is always at least 1.

internalItemsPerPage: number = 10

The internal tacker for the items per page count.

items: T[] = []

Current page's items.

wrapsAround: boolean

Boolean indicating whether the paginator should repeat or not.

Accessors

  • get hasNext(): boolean
  • Determine whether the paginator has a next page.

    Returns

    Returns boolean

  • get hasPrevious(): boolean
  • Determine whether the paginator has a previous page.

    Returns

    Returns boolean

Methods

  • Enable array like behaviour.

    Returns Iterator<T, any, undefined>

  • Determine whether the paginator has the given item.

    Parameters

    • item: T

    Returns boolean

  • Determine whether the given item is on page based on deep equality.

    Parameters

    • item: T

    Returns boolean

  • Private

    Get the page number where the item first occurs. If not found return -1

    Parameters

    • item: T

    Returns number

  • Remove and return the last element of the paginator.

    Returns

    Returns undefined | T

  • Add one or more items to the end of the paginator. Returns the new length of the paginator.

    Parameters

    • Rest ...items: T[]

    Returns number

  • Remove and return the first element of the paginator.

    Returns

    Returns undefined | T

  • Add one or more items to the beginning of the paginator. Returns the new length of the paginator.

    Parameters

    • Rest ...items: T[]

    Returns number

Generated using TypeDoc