EmoteParser

EmoteParser

new EmoteParser(fetcher, optionsopt)

Description:
  • A parser to replace text with emotes.

Source:
Parameters:
Name Type Attributes Default Description
fetcher EmoteFetcher

The fetcher to use the cache of.

options object <optional>
{}

Options for the parser.

Properties
Name Type Attributes Default Description
template string <optional>
''

The template to be used. The strings that can be interpolated are:

  • {link} The link of the emote.
  • {name} The name of the emote.
  • {size} The size index of the image.
  • {creator} The channel/owner name of the emote.
type 'html' | 'markdown' | 'bbcode' | 'plain' <optional>
'html'

The type of the parser. Can be one of html, markdown, bbcode, or plain. If the template option is provided, this is ignored.

match RegExp <optional>
/(\w+)/g

The regular expression that matches an emote. Must be a global regex, with one capture group for the emote code.

Members

fetcher :EmoteFetcher

Description:
  • The emote fetcher being used.

Source:

The emote fetcher being used.

Type:

options :object

Description:
  • The parser options.

Source:

The parser options.

Type:
  • object

Methods

(private) _validateOptions(optionsopt)

Description:
  • Validates the parser options.

Source:
Parameters:
Name Type Attributes Description
options object <optional>

Options for the parser.

Properties
Name Type Attributes Description
template string <optional>

The template to be used. The strings that can be interpolated are:

  • {link} The link of the emote.
  • {name} The name of the emote.
  • {size} The size of the image.
  • {creator} The channel/owner name of the emote.
type 'html' | 'markdown' | 'bbcode' | 'plain' <optional>

The type of the parser. Can be one of html, markdown, bbcode, or plain. If the template option is provided, this is ignored.

match RegExp <optional>

The regular expression that matches an emote. Must be a global regex, with one capture group for the emote code.

Throws:
  • When template is not a string.

    Type
    TypeError
  • When type is not one of the supported types.

    Type
    TypeError
  • When match is not a global RegExp.

    Type
    TypeError

parse(text, optionsopt) → {string}

Description:
  • Parses text.

Source:
Parameters:
Name Type Attributes Description
text string

Text to parse.

options object <optional>

Parameters for parsing.

Properties
Name Type Attributes Description
size number <optional>

Size (scale) for emotes.

forceStatic boolean <optional>

Whether to force the emote to be static (non-animated). Defaults to the fetcher's forceStatic or false.

themeMode 'dark' | 'light' <optional>

Only for Twitch: the preferred theme mode. Defaults to the fetcher's twitchThemeMode or dark.

Returns:
  • The parsed text.
Type
string