Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ValidToken<TType>

The class for all valid tokens.

Valid tokens always have a value, even if it might be an empty string.

Type parameters

Hierarchy

  • Token<true, TType, string, never>
    • ValidToken

Index

Constructors

Properties

Accessors

Methods

Constructors

  • new ValidToken<TType>(__namedParameters: { end: number; start: number; type: TType; value: string }): ValidToken<TType>

Properties

end: number
expected: never
start: number
type: TType
value: string

Accessors

Methods

  • Returns the canonical string version of the token (for valid tokens).

    For example, say the separators are ["-"] and the user inputs key\\-, the canonical version is the same because the - required escaping. But, say they inputted key\\+ thinking the + is a separator that needed to be escaped. This function will correctly return key+ in this situation.

    The main purpose is to provide some definitive string versions of tokens so at the higher node levels, the string versions of shortcuts can be used for normalizing shortcuts to check for equality. See Node.stringify for more.

    So it should also be specified when extending from this class to customize the canonical version of key notes ParserOptions.keyNote since you probably don't want something like key(note) to not be equal to key( note).

    The default implementation only needs to take care of how key and separator tokens are stringified.

    Parameters

    Returns string

Generated using TypeDoc