Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GrobberClient

A client for interacting with the Grobber API. Uses an internal cache with ExpiringItem.

The cache is realised using Memory.

Hierarchy

Implements

Index

Constructors

constructor

Properties

axiosClient

axiosClient: AxiosInstance

Private cachedRequestLock

cachedRequestLock: AsyncLock

Protected internalMemory

internalMemory: Namespace

memory

Methods

Protected assignMemory

checkGrobberInfo

forget

  • forget(key: string, forgetNamespace?: undefined | false | true): void
  • Delete the value of the provided namespace key.

    Parameters

    • key: string
    • Optional forgetNamespace: undefined | false | true

      if true this operation behaves like Memory.resetMemory with the key as an argument. Otherwise it merely removes the specified namespace.

    Returns void

getAnimeForTitle

getAnimeInfo

  • getAnimeInfo(uid: string): Promise<AnimeInfo>

getEpisode

  • getEpisode(uid: string, episodeIndex: number): Promise<Episode>

Private getExpiringItemFromMemory

  • getExpiringItemFromMemory(key: string): any

getGrobberInfo

  • getGrobberInfo(baseURL?: undefined | string): Promise<GrobberInfo>

Private performCachedRequest

  • performCachedRequest(endpoint: string, paramsList: Array<[string, any]>, respHandler?: undefined | function): Promise<any>
  • Parameters

    • endpoint: string
    • paramsList: Array<[string, any]>
    • Optional respHandler: undefined | function

    Returns Promise<any>

remember

  • remember(key: string, value: any): void
  • Store the given value under the namespace key.

    Parameters

    • key: string

      Namespaces are separated by a dot

    • value: any

    Returns void

Private rememberExpiring

  • rememberExpiring(key: string, item: any, ttl: number): any

request

  • request(endpoint: string, params?: undefined | object): Promise<any>
  • Perform a request to the given Grobber endpoint with the given parameters. The base url is read from the Config.

    throws

    GrobberResponseError - If Grobber returned an error response.

    throws

    GrobberRequestError - If a request was made but there was no response

    throws

    Error - When anything goes wrong while setting up the request. This (probably) should't occur during normal operation.

    Parameters

    • endpoint: string
    • Optional params: undefined | object

    Returns Promise<any>

resetMemory

  • resetMemory(...namespaces: string[]): void
  • Reset the given namespaces and all their children.

    When called with no arguments this flushes the entire memory (i.e. deletes all keys).

    see

    Memory.forget to remove a specific namespace without affecting its children.

    Parameters

    • Rest ...namespaces: string[]

    Returns void

searchAnime

Generated using TypeDoc