magiclogger - v0.1.0
    Preparing search index...

    Function applyStyles

    Style extraction and reconstruction utilities for MAGIC schema. These functions enable parsing styled text and reconstructing it from MAGIC log entries.

    • Applies style ranges back to plain text to reconstruct styled output.

      Parameters

      • plainText: string

        Plain text message

      • Optionalstyles: StyleRange[]

        Array of style ranges

      • applyStyleFn: (text: string, style: string) => string = ...

        Function to apply a style to text

      Returns string

      Styled text

      const styled = applyStyles(
      "Error: User john@example.com not found",
      [[0, 6, "red.bold"], [12, 29, "cyan"]],
      (text, style) => `<${style}>${text}</>`
      );
      // Returns: "<red.bold>Error:</> User <cyan>john@example.com</> not found"