Options
All
  • Public
  • Public/Protected
  • All
Menu

Utility to paginate data.

Type parameters

  • T

Hierarchy

  • Paginator

Implements

  • Iterable<T>

Index

Constructors

  • new Paginator<T>(elements?: MaybeArray<T>, itemsPerPage?: number, wrapsAround?: boolean): 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 currentPage(): number
  • get hasNext(): boolean
  • get hasPrevious(): boolean
  • get itemsPerPage(): number
  • get length(): number
  • get pageCount(): number

Methods

  • [iterator](): Iterator<T, any, undefined>
  • Enable array like behaviour.

    Returns Iterator<T, any, undefined>

  • getAll(): T[]
  • getPages(): T[][]
  • has(item: T): boolean
  • isOnPage(item: T): boolean
  • Determine whether the given item is on page based on deep equality.

    Parameters

    • item: T

    Returns boolean

  • pageNumberOf(item: T): number
  • Get the page number where the item first occurs. If not found return -1

    Parameters

    • item: T

    Returns number

  • pop(): undefined | T
  • push(...items: T[]): number
  • Add one or more items to the end of the paginator. Returns the new length of the paginator.

    Parameters

    • Rest ...items: T[]

    Returns number

  • shift(): undefined | T
  • unshift(...items: T[]): number
  • 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