- 
        Couldn't load subscription status. 
- Fork 49
Yantra
        Taritsyn edited this page Jul 15, 2025 
        ·
        16 revisions
      
    JavaScriptEngineSwitcher.Yantra contains a YantraJsEngine adapter (wrapper for the YantraJS version 1.2.286).
You can specify a settings of JS engine during its registration:
engineSwitcher.EngineFactories
    .AddYantra(new YantraSettings
    {
        ConsoleCallback = (string type, object[] args) =>
        {
            TextWriter writer = type == "error" ? Console.Error : Console.Out;
            if (type != "log")
            {
                ConsoleColor typeColor;
                switch (type)
                {
                    case "warn":
                        typeColor = ConsoleColor.Yellow;
                        break;
                    case "error":
                        typeColor = ConsoleColor.Red;
                        break;
                    default:
                        typeColor = ConsoleColor.White;
                        break;
                }
                Console.ForegroundColor = typeColor;
                writer.Write("{0}: ", type);
            }
            Console.ForegroundColor = ConsoleColor.White;
            for (int argIndex = 0; argIndex < args.Length; argIndex++)
            {
                if (argIndex > 0)
                {
                    writer.Write(" ");
                }
                writer.Write(args[argIndex] ?? "null");
            }
            writer.WriteLine();
        }
    })
    ;If you manually create an instance of JS engine, then you can pass settings via the constructor:
IJsEngine engine = new YantraJsEngine(
    new YantraSettings
    {
        ConsoleCallback = (string type, object[] args) =>
        {
            …
        }
    }
);Consider in detail properties of the YantraSettings class:
| Property name | Data type | Default value | Description | 
|---|---|---|---|
| ConsoleCallback | YantraJsConsoleCallbackdelegate | null | JS debugging console callback. | 
| Debugger | YantraJS.Debugger.JSDebugger | null | Instance of JS debugger (for example, the YantraJS.Core.Debugger.V8Debugger) | 
- Registration of JS engines
- Creating instances of JS engines
- JS engines
- Upgrade guides
- Additional reading and resources