Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ProviderStore

Stores all Provider pieces for use in Klasa.

since

0.1.0

Hierarchy

Index

Constructors

constructor

Properties

Readonly Holds

Holds: PieceConstructor<Provider>

The type of structure this store holds.

since

0.0.1

Readonly client

client: Client

The client this Store was created with.

since

0.0.1

Protected Readonly coreDirectories

coreDirectories: Set<string>

The core directories pieces of this store can hold.

since

0.0.1

Readonly name

name: string

The name of this store.

since

0.0.1

Readonly size

size: number

Accessors

default

first

  • get first(): [string, Provider] | null
  • The first item in this Cache

    Returns [string, Provider] | null

firstKey

  • get firstKey(): string | null
  • The first key of this cache

    Returns string | null

firstValue

last

  • The last item in this cache

    Returns [string, Provider] | null

lastKey

  • get lastKey(): string | null
  • The last key of this cache

    Returns string | null

lastValue

userDirectory

  • get userDirectory(): string
  • The directory of local pieces relative to where you run Klasa from.

    since

    0.0.1

    Returns string

Static [Symbol.species]

  • get [Symbol.species](): typeof Cache

Methods

add

  • Adds and sets up a piece in our store.

    since

    0.0.1

    Parameters

    • piece: Provider

      The piece we are setting up

    Returns Provider | null

clear

  • clear(): void

clone

  • Returns a shallow clone of this Cache

    Returns Cache<string, Provider>

concat

  • Returns a new Cache with this and other caches together

    Parameters

    • Rest ...caches: Cache<string, Provider>[]

      Other caches to include in the new cache

    Returns Cache<string, Provider>

delete

  • delete(): never
  • The overriden delete method, this will always throw.

    internal

    Returns never

equals

  • equals(cache: Cache<string, Provider>): boolean
  • Naive equality compare function

    Parameters

    • cache: Cache<string, Provider>

      The cache to compare this against

    Returns boolean

every

  • every(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): boolean
  • Tests if every entry in this cache meets a condition

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      The function to test the condition

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns boolean

filter

  • filter(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): Cache<string, Provider>
  • Returns a new filtered Cache based on the filter function

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      Function used to determine what entries are in the new Cache

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns Cache<string, Provider>

find

  • find(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): [string, Provider] | undefined
  • Finds an entry from this Cache

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      Function used to find what you are looking for

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns [string, Provider] | undefined

findKey

  • findKey(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): string | undefined
  • Finds a key from this Cache

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      Function used to find what you are looking for

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns string | undefined

findValue

  • findValue(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): Provider | undefined
  • Finds a value from this Cache

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      Function used to find what you are looking for

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns Provider | undefined

forEach

  • forEach(callbackfn: (value: Provider, key: string, map: Map<string, Provider>) => void, thisArg?: any): void

get

  • get(key: string): Provider | undefined
  • Parameters

    • key: string

    Returns Provider | undefined

has

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

init

  • init(): Promise<Array<any>>
  • Initializes all pieces in this store.

    since

    0.0.1

    Returns Promise<Array<any>>

load

  • load(directory: string, file: keyof string[]): Promise<Provider | null>
  • Loads a piece into Klasa so it can be saved in this store.

    since

    0.0.1

    Parameters

    • directory: string

      The directory the file is located in

    • file: keyof string[]

      A string or array of strings showing where the file is located.

    Returns Promise<Provider | null>

loadAll

  • loadAll(): Promise<number>
  • Loads all of our Pieces from both the user and core directories.

    since

    0.0.1

    Returns Promise<number>

    The number of Pieces loaded.

map

  • map<T>(fn: (value: Provider, key: string, map: this) => T, thisArg?: any): T[]
  • Maps this Cache to an array (like Array#map())

    Type parameters

    • T

    Parameters

    • fn: (value: Provider, key: string, map: this) => T

      Function to determine what is mapped to the new Array

        • (value: Provider, key: string, map: this): T
        • Parameters

          Returns T

    • Optional thisArg: any

      Optional binding for the fn param

    Returns T[]

reduce

  • reduce<I>(fn: (accumulator: I, value: Provider, key: string, map: this) => I, initialValue: I, thisArg?: any): I
  • Reduces this cache into a singularity

    Type parameters

    • I

    Parameters

    • fn: (accumulator: I, value: Provider, key: string, map: this) => I

      The function to determine how this Cache is reduced

        • (accumulator: I, value: Provider, key: string, map: this): I
        • Parameters

          • accumulator: I
          • value: Provider
          • key: string
          • map: this

          Returns I

    • initialValue: I

      The initial value

    • Optional thisArg: any

      Optional binding for the fn param

    Returns I

registerCoreDirectory

  • registerCoreDirectory(directory: string): this
  • Registers a core directory to check for pieces.

    since

    0.0.1

    Parameters

    • directory: string

      The directory to check for core pieces

    Returns this

remove

  • remove(name: string | Provider): boolean

resolve

  • Resolve a string or piece into a piece object.

    since

    0.0.1

    Parameters

    • name: Provider | string

      The piece object or a string representing a piece's name

    Returns Provider | null

set

  • set(): never
  • The overriden set method, this will always throw.

    internal

    Returns never

some

  • some(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): boolean
  • Tests if some entries in this cache meets a condition

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      The function to test the condition

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns boolean

sort

  • sort(compareFunction?: undefined | ((v0: Provider, v1: Provider, k0?: K, k1?: K) => number)): this
  • Sorts entries in-place in this Cache

    Parameters

    • Optional compareFunction: undefined | ((v0: Provider, v1: Provider, k0?: K, k1?: K) => number)

      Function to determine how this Cache should be sorted

    Returns this

sorted

  • sorted(compareFunction?: undefined | ((v0: Provider, v1: Provider, k0?: K, k1?: K) => number)): Cache<string, Provider>
  • Sorts entries in a new Cache

    Parameters

    • Optional compareFunction: undefined | ((v0: Provider, v1: Provider, k0?: K, k1?: K) => number)

      Function to determine how the resulting Cache should be sorted

    Returns Cache<string, Provider>

sweep

  • sweep(fn: (value: Provider, key: string, map: this) => boolean, thisArg?: any): number
  • Sweeps entries from this Cache

    Parameters

    • fn: (value: Provider, key: string, map: this) => boolean

      Function used to determine what entries are swept

        • (value: Provider, key: string, map: this): boolean
        • Parameters

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns number

toString

  • toString(): string
  • Defines toString behavior for stores

    since

    0.0.1

    Returns string

    This store name

Generated using TypeDoc