@witchcraft/spellcraft
    Preparing search index...

    The default class based implementation of the IStringifier interface.

    It can be passed (and a default instance is passed by default) to most functions to specify how to stringify items in errors.

    The default method stringify can be called with any key, chord, chain, shortcut, etc. and calls the respective DefaultStringifierOptions method depending on the type property or in the case of chains, chords, and keys, the array depth.

    That method called then calls any others it needs (e.g. if you pass a shortcut, it will call stringifyShortcut which will call stringifyCommand, stringifyCondition, and stringifyChain, which will call stringifyChord and so on)

    These can be customized by changing the options of the default instance (see Customizing below). These options are methods that describe in simpler term how items should be joined, without handling all the logic (the class pieces it all together)

    For chains the default method uses a key's label and combines keys inside chords with + and the chords of shortcut chains with a space .

    Key+Key Key+Key+Key
    ^Chord^ ^Chord ^
    ^Chain ^

    For shortcuts, the default is:

    Shortcut Key+Key Key+Key+Key (command: command_name, condition: condition_text)
    

    If the condition or command are undefined: - For command it will still say it's undefined. - The condition is removed entirely if it's undefined.

    Shortcut Key+Key Key+Key+Key (command: undefined)
    

    stringifyLists returns a lists joined by a comma and new line:

    	 item,
    item

    Ideally a single stringifier should be created and shared amongst all instances. This is already taken care of if you do not pass a custom stringifier, a default stringifier instance is re-used throughout. Unless you're implementing your own IStringifier, you should not need to pass the default one around.

    You can just import it early and change it's options.

    Implements

    Index

    Constructors

    Properties

    Methods

    • Parameters

      • entry: string | string[] | string[][]
      • manager: Pick<Manager, "keys">

      Returns string

    • Stringifies single keys in string or Key from, as well as chords, chains, full shortcuts, and commands.

      In the case of string key ids and Shortcuts, some additional information is required to be able to convert the keys and commands back into the full commands and consistently stringify them.

      Parameters

      Returns string

    • Parameters

      Returns string

    • Stringifies lists of keys, shortcuts, or commands.

      The type must be specified because we can't magically tell what type something is for string lists and/or empty lists.

      Parameters

      • type: "keys"
      • entries: Key[]

      Returns string

    • Parameters

      Returns string

    • Parameters

      • type: "keys"
      • entries: string[]
      • manager: Pick<Manager, "keys">

      Returns string

    • Parameters

      • type: "commands"
      • entries: string[]
      • manager: Pick<Manager, "commands">

      Returns string

    • Parameters

      Returns string

    • Stringifies the property values of items when there is an error (e.g. "You cannot change prop x from a to b because of y." a and b here being the property values).

      Parameters

      • entry: any

      Returns string