kyrie
    Preparing search index...

    Function ansi_from_string

    • Converts a JSON or JavaScript string to ANSI-colored terminal output Convenience function that parses the string and paints it with ANSI codes

      Parameters

      • str: string

        The string to convert to ANSI output (JSON or JavaScript literal)

      • Optionaloptions: Options

        Optional configuration for highlighting

      Returns string

      String with ANSI color codes for terminal display

      const json = '{"name": "Alice", "age": 30}';
      const ansi = ansi_from_string(json);
      console.log(ansi); // Outputs colorized in terminal
      const arr = '[1, 2, 3, "hello", true]';
      const ansi = ansi_from_string(arr, { palette: palettes.bold.dark });
      console.log(ansi); // Outputs with ANSI color codes