Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Schema

Hierarchy

Index

Constructors

constructor

Properties

Readonly defaults

defaults: Settings

The defaults for this schema.

ready

ready: boolean

Whether or not this instance is ready.

Readonly size

size: number

Accessors

first

  • The first item in this Cache

    Returns [string, SchemaEntry] | 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, SchemaEntry] | null

lastKey

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

    Returns string | null

lastValue

Methods

add

  • Add a new entry to the schema.

    example

    // Create a schema with a key of experience: new Schema() .add('experience', 'integer', { minimum: 0 });

    example

    // Modify the built-in user schema to add experience and level: KlasaClient.defaultUserSchema .add('experience', 'integer', { minimum: 0 }) .add('level', 'integer', { minimum: 0 });

    Parameters

    • key: string

      The name for the key to add

    • type: string

      The datatype, will be lowercased in the instance

    • Optional options: SchemaEntryOptions

      The options for the entry

    Returns this

clear

  • clear(): void
  • Returns void

clone

  • Returns a shallow clone of this Cache

    Returns Cache<string, SchemaEntry>

concat

  • Returns a new Cache with this and other caches together

    Parameters

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

      Other caches to include in the new cache

    Returns Cache<string, SchemaEntry>

delete

  • delete(key: string): boolean

equals

  • Naive equality compare function

    Parameters

    • cache: Cache<string, SchemaEntry>

      The cache to compare this against

    Returns boolean

every

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

    Parameters

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

      The function to test the condition

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns boolean

filter

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

    Parameters

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

      Function used to determine what entries are in the new Cache

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns Cache<string, SchemaEntry>

find

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

    Parameters

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

      Function used to find what you are looking for

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns [string, SchemaEntry] | undefined

findKey

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

    Parameters

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

      Function used to find what you are looking for

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns string | undefined

findValue

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

    Parameters

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

      Function used to find what you are looking for

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns SchemaEntry | undefined

forEach

get

  • Parameters

    • key: string

    Returns SchemaEntry | undefined

has

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

map

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

    Type parameters

    • T

    Parameters

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

      Function to determine what is mapped to the new Array

        • Parameters

          Returns T

    • Optional thisArg: any

      Optional binding for the fn param

    Returns T[]

reduce

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

    Type parameters

    • I

    Parameters

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

      The function to determine how this Cache is reduced

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

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

          Returns I

    • initialValue: I

      The initial value

    • Optional thisArg: any

      Optional binding for the fn param

    Returns I

set

some

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

    Parameters

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

      The function to test the condition

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns boolean

sort

  • Sorts entries in-place in this Cache

    Parameters

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

      Function to determine how this Cache should be sorted

    Returns this

sorted

  • Sorts entries in a new Cache

    Parameters

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

      Function to determine how the resulting Cache should be sorted

    Returns Cache<string, SchemaEntry>

sweep

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

    Parameters

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

      Function used to determine what entries are swept

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

          Returns boolean

    • Optional thisArg: any

      Optional binding for the fn param

    Returns number

toJSON

Generated using TypeDoc