Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Extender

The extender class that allows the extension of built-in structures from Klasa-Core and plugins.

Hierarchy

Index

Properties

Readonly size

size: number

Accessors

first

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

    Returns [keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]] | null

firstKey

  • The first key of this cache

    Returns keyof ExtenderStructures | null

firstValue

  • get firstValue(): ExtenderStructures[keyof ExtenderStructures] | null
  • The first value of this cache

    Returns ExtenderStructures[keyof ExtenderStructures] | null

last

  • get last(): [keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]] | null
  • The last item in this cache

    Returns [keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]] | null

lastKey

  • The last key of this cache

    Returns keyof ExtenderStructures | null

lastValue

  • get lastValue(): ExtenderStructures[keyof ExtenderStructures] | null
  • The last value of this cache

    Returns ExtenderStructures[keyof ExtenderStructures] | null

Methods

add

  • add<K, V>(key: K, fn: V): this
  • Adds a new entry to this instance so it can be extended. Throws if a structure with the same name was already set.

    Type parameters

    Parameters

    • key: K

      The name of the structure to be set

    • fn: V

      The class to be added to the registry

    Returns this

clear

  • clear(): void
  • Returns void

clone

  • Returns a shallow clone of this Cache

    Returns Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>

concat

  • Returns a new Cache with this and other caches together

    Parameters

    • Rest ...caches: Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>[]

      Other caches to include in the new cache

    Returns Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>

delete

  • delete(): never

equals

  • equals(cache: Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>): boolean
  • Naive equality compare function

    Parameters

    • cache: Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>

      The cache to compare this against

    Returns boolean

every

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

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      The function to test the condition

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns boolean

extend

  • extend<K, R>(key: K, fn: (structure: ExtenderStructures[K]) => R): this
  • Extends a structure by its registered name.

    example

    const { extender } = require('@klasa/core'); const { Settings } = require('klasa');

    extender.extend('TextChannel', (TextChannel) => class extends TextChannel {

    constructor(...args) { super(...args); this.settings = new Settings(this.client, 'textChannels', this.id); }

    });

    Type parameters

    Parameters

    • key: K

      The name of the structure to be extended

    • fn: (structure: ExtenderStructures[K]) => R

      A callback returning the extended class

        • (structure: ExtenderStructures[K]): R
        • Parameters

          • structure: ExtenderStructures[K]

          Returns R

    Returns this

filter

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

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      Function used to determine what entries are in the new Cache

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>

find

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

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      Function used to find what you are looking for

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns [keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]] | undefined

findKey

  • Finds a key from this Cache

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      Function used to find what you are looking for

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns keyof ExtenderStructures | undefined

findValue

  • findValue(fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean, thisArg?: any): ExtenderStructures[keyof ExtenderStructures] | undefined
  • Finds a value from this Cache

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      Function used to find what you are looking for

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns ExtenderStructures[keyof ExtenderStructures] | undefined

forEach

  • forEach(callbackfn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: Map<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>) => void, thisArg?: any): void
  • Parameters

    • callbackfn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: Map<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>) => void
        • Parameters

          Returns void

    • Optional thisArg: any

    Returns void

get

  • get<K>(key: K): ExtenderStructures[K]
  • get(key: string): undefined

has

  • Parameters

    Returns boolean

map

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

    Type parameters

    • T

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => T

      Function to determine what is mapped to the new Array

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): T
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns T

    • Optional thisArg: any

      Optional binding for the fn param

    Returns T[]

reduce

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

    Type parameters

    • I

    Parameters

    • fn: (accumulator: I, value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => I

      The function to determine how this Cache is reduced

        • (accumulator: I, value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): I
        • Parameters

          • accumulator: I
          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns I

    • initialValue: I

      The initial value

    • Optional thisArg: any

      Optional binding for the fn param

    Returns I

set

  • set(): never
  • The overriden set method, this will always throw. Use {@link Extender#add} for adding new structures, or {@link Extender#extend} to extend an existing one.

    internal

    Returns never

some

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

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      The function to test the condition

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns boolean

sort

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

    Parameters

    • Optional compareFunction: undefined | ((v0: ExtenderStructures[keyof ExtenderStructures], v1: ExtenderStructures[keyof ExtenderStructures], k0?: K, k1?: K) => number)

      Function to determine how this Cache should be sorted

    Returns this

sorted

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

    Parameters

    • Optional compareFunction: undefined | ((v0: ExtenderStructures[keyof ExtenderStructures], v1: ExtenderStructures[keyof ExtenderStructures], k0?: K, k1?: K) => number)

      Function to determine how the resulting Cache should be sorted

    Returns Cache<keyof ExtenderStructures, ExtenderStructures[keyof ExtenderStructures]>

sweep

  • sweep(fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean, thisArg?: any): number
  • Sweeps entries from this Cache

    Parameters

    • fn: (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this) => boolean

      Function used to determine what entries are swept

        • (value: ExtenderStructures[keyof ExtenderStructures], key: keyof ExtenderStructures, map: this): boolean
        • Parameters

          • value: ExtenderStructures[keyof ExtenderStructures]
          • key: keyof ExtenderStructures
          • map: this

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns number

Generated using TypeDoc