Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TagCollection

A collection of tags - helpful for fetching a list of tags while only making enough HTTP requests to satisfy needs

export
class

TagCollection

extends

{Collection<number, Tag>}

Hierarchy

Implements

  • AsyncIterable<Tag>

Index

Constructors

constructor

Properties

Protected _cache

_cache: Map<number, Tag> = new Map<T1, T2>()

Protected _ids

_ids: number[]

Protected _pointer

_pointer: number = 0

Methods

[Symbol.asyncIterator]

  • [Symbol.asyncIterator](): AsyncIterableIterator<Tag>

every

  • every(fn: function): Promise<boolean>
  • Returns true if every element in the collection matches some conditional

    memberof

    Collection

    Parameters

    • fn: function

      The function used to check each element

        • (value: Tag): boolean
        • Parameters

          Returns boolean

    Returns Promise<boolean>

    A Promise wrapping a boolean stating whether or not the condition matched every element

find

  • find(fn: function): Promise<Tag | null>
  • Finds the first item in the collection matching some condition

    memberof

    Collection

    Parameters

    • fn: function

      The function to filter elements with

        • (value: Tag): boolean
        • Parameters

          Returns boolean

    Returns Promise<Tag | null>

    The found value (null if no items in the collection that match)

first

  • first(): Promise<Tag | null>
  • Gets the first item in the collection

    memberof

    Collection

    Returns Promise<Tag | null>

    A Promise wrapping the retrieved value (null if no items in the collection)

get

  • get(id: number): Promise<Tag>

last

  • last(): Promise<Tag | null>
  • Gets the last item in the collection

    memberof

    Collection

    Returns Promise<Tag | null>

    A Promise wrapping the retrieved value (null if no items in the collection)

map

  • map<T>(fn: function): Promise<T[]>
  • Maps all elements of the collection over some function

    template

    T The type of array to return

    memberof

    Collection

    Type parameters

    • T

    Parameters

    • fn: function

      The function to map to every element in the collection

        • (value: Tag): T
        • Parameters

          Returns T

    Returns Promise<T[]>

    A Promise wrapping the array returned

next

  • next(): Promise<IteratorResult<Tag>>
  • Fetches the next element in the collection, as well as whether or not iteration is done

    memberof

    Collection

    Returns Promise<IteratorResult<Tag>>

    The next element

random

  • random(): Promise<Tag | null>
  • Gets a random element from the collection

    memberof

    Collection

    Returns Promise<Tag | null>

    A Promise wrapping the retrieved value (null if no items in the collection)

reduce

  • reduce<T>(fn: function, initialAcc: T): Promise<T>
  • Reduces the collection into some value

    Similar to Array#reduce

    template

    T The type of the accumulator

    memberof

    Collection

    Type parameters

    • T

    Parameters

    • fn: function

      The function used to reduce each element ()

        • (acc: T, value: Tag): T
        • Parameters

          • acc: T
          • value: Tag

          Returns T

    • initialAcc: T

      The initial value for the accumulator

    Returns Promise<T>

    A Promise wrapping the final accumulator value

some

  • some(fn: function): Promise<boolean>
  • Returns true if some of the elements in the collection match some conditional function

    memberof

    Collection

    Parameters

    • fn: function

      The function used to check each element

        • (value: Tag): boolean
        • Parameters

          Returns boolean

    Returns Promise<boolean>

    A Promise wrapping a boolean stating whether or not the condition matched at least one element

tap

  • Identical to map, but returns this instead of an array

    see

    map

    memberof

    Collection

    Parameters

    • fn: function

      The function to map over each element

        • (value: Tag): any
        • Parameters

          Returns any

    Returns Promise<Collection<number, Tag>>

    The current collection

Generated using TypeDoc