Options
All
  • Public
  • Public/Protected
  • All
Menu

Module vorple

Index

Type Aliases

VorpleEventCategory: "init" | "expectCommand" | "submitCommand" | "expectKeypress" | "submitKeypress" | "quit"
VorpleEventListener: ((meta: VorpleEventMetadata) => Promise<unknown> | unknown)

Type declaration

Functions

  • checkVersion(versionRange: string): boolean
  • Checks that the library's version matches the given version range. See https://github.com/npm/node-semver#ranges for the full syntax.

    example

    If the library version is e.g. 3.2.8 the following return true:

    vorple.checkVersion("3.2")
    vorple.checkVersion(">=3.2.8")
    vorple.checkVersion("<3.3")
    vorple.checkVersion("3.2.8 || >=4")
    vorple.checkVersion("3.1 - 3.2")
    vorple.checkVersion("~3.2.5")

    The following return false:

    vorple.checkVersion(">=4.0")
    vorple.checkVersion("<3.2.8")
    vorple.checkVersion("~3.2.9")
    since

    3.2.8

    Parameters

    • versionRange: string

      The version range to check

    Returns boolean

    True if version matches the given range, false otherwise.

  • evaluate(code: string): void
  • Evaluates JavaScript code and writes the return value and its type to the virtual filesystem for the story file to read.

    Parameters

    • code: string

      JavaScript code to evaluate

    Returns void

  • getInformVersion(): 6 | 7 | undefined
  • Returns the Inform version, detected at handshake. Before the handshake the value is undefined.

    since

    3.2.0

    Returns 6 | 7 | undefined

  • init(): Promise<void>
  • Initializes and starts Vorple.

    Returns Promise<void>

    The function returns a promise that's resolved when the init event has triggered and the virtual filesystem has started. The promise won't wait for the story file to load.

  • Removes a registered event listener.

    since

    3.2.0

    Parameters

    • eventNames: VorpleEventCategory | VorpleEventCategory[]

      The event name or an array of event names from where to remove the listener. Leaving this parameter out completely (i.e. passing the listener function as the first and only parameter) removes the listener from all events where it's been registered.

    • listener: VorpleEventListener

      The listener to remove

    Returns boolean

    Returns true if the listener was removed from at least one event.

  • requireVersion(requiredVersion: string, callback?: ((versionMatches: boolean) => void)): boolean
  • Require a minimum version of Vorple. Minor updates are accepted if they're not specified in the request. In other words, if version "3.1" is requested, then any Vorple version below 3.2 (3.1, 3.1.1, 3.1.2 etc) will pass. If version "3" is requested, every version 3.x.x will pass.

    If an optional callback is passed to the function, it will be run with one boolean parameter: true if version matches, false otherwise. Otherwise an error is thrown if the version doesn't match.

    deprecated

    Deprecated since 3.2.8 in favor of the more versatile checkVersion. The equivalent of e.g. vorple.requireVersion("3.2") is vorple.checkVersion(">=3.2").

    Parameters

    • requiredVersion: string

      The minimum version of Vorple that's required

    • Optional callback: ((versionMatches: boolean) => void)

      If an optional callback function is passed, it will be run with one boolean parameter: true if version matches, false otherwise. If a callback isn't provided, this function throws an error if the version doesn't match.

        • (versionMatches: boolean): void
        • Parameters

          • versionMatches: boolean

          Returns void

    Returns boolean

    Returns true if version matches.

  • setInformVersion(version: 7 | 6): void
  • Sets the Inform version.

    since

    3.2.0

    internal

    Parameters

    • version: 7 | 6

    Returns void

Generated using TypeDoc