Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Enums

Index

Functions

entries

  • entries<T>(enumObject: T): ReadonlyArray<[keyof T]>
  • Iterate over the entries in an enum. Yields a tuple containing the name and value of each entry.

    Type parameters

    • T

    Parameters

    • enumObject: T

    Returns ReadonlyArray<[keyof T]>

entryStream

  • entryStream<T>(enumObject: T): Stream<[keyof T]>
  • Type parameters

    • T

    Parameters

    • enumObject: T

    Returns Stream<[keyof T]>

findByName

  • findByName<E, K>(enumObject: {}, name: K): E
  • Returns an enum entry by its name, case-insensitive.

    Type parameters

    • E

    • K: string

    Parameters

    • enumObject: {}

      The full enumeration. EG: ItemType, CreatureType, DoodadType, etc

    • name: K

      The name of the enum entry. Case-insensitive.

    Returns E

    The enum entry, if found; otherwise undefined.

getLength

  • getLength(enumObject: any): number
  • Returns the number of entries in this enum.

    Parameters

    • enumObject: any

      The full enumeration. EG: ItemType, CreatureType, DoodadType, etc

    Returns number

getMod

  • getMod<O>(enumObject: O, entry: O[keyof O], isGlobalEnum?: undefined | false | true): IModInfo | undefined
  • Type parameters

    • O

    Parameters

    • enumObject: O
    • entry: O[keyof O]
    • Optional isGlobalEnum: undefined | false | true

    Returns IModInfo | undefined

getModFromName

  • getModFromName<O>(enumObject: O, enumName: keyof O, isGlobalEnum?: undefined | false | true): IModInfo | undefined
  • Type parameters

    • O

    Parameters

    • enumObject: O
    • enumName: keyof O
    • Optional isGlobalEnum: undefined | false | true

    Returns IModInfo | undefined

getModStart

  • getModStart(enumObject: any): number
  • Parameters

    • enumObject: any

    Returns number

getNth

  • getNth<E, K>(enumObject: {}, n: number): Exclude<E, AnyFunction> | undefined
  • Returns an enum entry by its index. The order is not guaranteed.

    Type parameters

    • E

    • K: string

    Parameters

    • enumObject: {}

      The full enumeration. EG: ItemType, CreatureType, DoodadType, etc

    • n: number

      The index of the enum entry.

    Returns Exclude<E, AnyFunction> | undefined

    The enum entry, or if out of bounds, undefined.

getRandom

  • getRandom<T>(enumObject: T, filter?: undefined | ((value: T[keyof T], index: number) => boolean), random?: Random<SeededGenerator>): T[keyof T] extends (...args: any[]) => R ? never : T[keyof T]
  • Returns a random enum entry.

    Type parameters

    • T

    Parameters

    • enumObject: T

      The full enumeration. EG: ItemType, CreatureType, DoodadType, etc

    • Optional filter: undefined | ((value: T[keyof T], index: number) => boolean)

      Repeats the choice until the random value matches the filter

    • Default value random: Random<SeededGenerator> = seededRandom

      The random instance to use. Defaults to seeded random. Note that using this method in non-game locations may cause seed desyncs!

    Returns T[keyof T] extends (...args: any[]) => R ? never : T[keyof T]

isModdable

  • isModdable(enumObject: any): boolean
  • Parameters

    • enumObject: any

    Returns boolean

isModded

  • isModded<E, K>(enumObject: {}, entry: E): boolean
  • Returns whether this enum entry is modded.

    Type parameters

    • E

    • K: string

    Parameters

    • enumObject: {}

      The full enumeration. EG: ItemType, CreatureType, DoodadType, etc

    • entry: E

      The entry in the enum. Usually its index.

    Returns boolean

isModdedAndLoaded

  • isModdedAndLoaded(enumObject: any, key: string): boolean
  • Parameters

    • enumObject: any
    • key: string

    Returns boolean

isValid

  • isValid<E, K>(enumObject: {}, entry: unknown, isBasicEnum?: boolean): entry is E
  • Returns whether the given number is a valid entry in an enum.

    Type parameters

    • E

    • K: string

    Parameters

    • enumObject: {}

      The enum object to check for the entry.

    • entry: unknown

      The value to check.

    • Default value isBasicEnum: boolean = true

      Whether the enum is a "basic" enum; IE, every entry is a number between 0 and Infinity. (Default: true)

    Returns entry is E

keyStream

  • keyStream<T>(enumObject: T): Stream<keyof T>
  • Iterate over the names of the entries in an enum.

    Type parameters

    • T

    Parameters

    • enumObject: T

    Returns Stream<keyof T>

keys

  • keys<T>(enumObject: T): ReadonlyArray<keyof T>
  • Get the names of the entries in an enum.

    Type parameters

    • T

    Parameters

    • enumObject: T

    Returns ReadonlyArray<keyof T>

sortKeysByOrdinal

  • sortKeysByOrdinal<E, K>(enumObject: {}): (Anonymous function)
  • Type parameters

    • E: number

    • K: string

    Parameters

    • enumObject: {}

    Returns (Anonymous function)

toString

  • toString(enumObject: any, n: number, exlude?: undefined | number): string
  • Parameters

    • enumObject: any
    • n: number
    • Optional exlude: undefined | number

    Returns string

valueStream

  • valueStream<T>(enumObject: T): Stream
  • Type parameters

    • T

    Parameters

    • enumObject: T

    Returns Stream

values

  • values<T>(enumObject: T): ReadonlyArray<T[keyof T] extends (...args: any[]) => R ? never : T[keyof T]>
  • Iterate over the values in an enum.

    Type parameters

    • T

    Parameters

    • enumObject: T

    Returns ReadonlyArray<T[keyof T] extends (...args: any[]) => R ? never : T[keyof T]>

Generated using TypeDoc