splitMessage()function

splitMessage(input: PossibleMessage): ImmutableDictionary<string>
ParamType
inputPossibleMessage
The value to read a message from (a string, or an object with a message string). required
Return
ImmutableDictionary<string>
Dictionary mapping each name (or "" for unnamed lines) to its combined message.
Throws
unknown
RequiredError if no message could be found.

Split a string message into lines, look for prefixes like name:, and return a dictionary of those named messages.

  • Full messages strings can have multiple lines separated by \n newline.
  • Named messages are extracted into their own entries in the dictionary.
  • Unnamed messages are combined into a single entry with the key "" (empty string).

Examples

splitMessage("name: Bad\nUh oh") // { name: "Bad", "": "Uh oh" }