Javascript Interpreter for C# (no dependencies)
#scripting #script-engine

Sebastien Ros 0e332ddad8 Adding Options.AllowDebuggerStatement hace 11 años
.nuget 9b18dabfed Adding missing nuget.exe hace 11 años
Jint 0e332ddad8 Adding Options.AllowDebuggerStatement hace 11 años
Jint.Benchmark d2a5131df8 Enabling nuget package restore for CI hace 11 años
Jint.Repl 6fb1d4789d Implementing object interop hace 11 años
Jint.Tests 0e332ddad8 Adding Options.AllowDebuggerStatement hace 11 años
Jint.Tests.CommonScripts 3c9bf7fc63 Moving SunSpider tests to its own assembly hace 11 años
Jint.Tests.Ecma f1d274db42 Finalizing String tests suite hace 11 años
Jint.Tests.Scaffolding b6d60818da Adding Ecma 262 tests hace 12 años
.gitignore 2dab8046d6 Scaffolding project vs. hand written classes hace 12 años
CREDITS.txt f53137698a Adding license information hace 11 años
Jint.sln 3c9bf7fc63 Moving SunSpider tests to its own assembly hace 11 años
Jint.sln.DotSettings 478662033e Refactoring Date to reflect specifications hace 11 años
LICENSE.txt f53137698a Adding license information hace 11 años
README.md d1ad5f4d02 Re-adding build status badge hace 11 años

README.md

Build status

Jint

Jint is a Javascript interpreter for .NET. Jint doesn't compile Javascript to .NET bytecode and in this sense might be best suited for projects requiring to run relatively small scripts faster, or which need to run on different platforms.

Objectives

Example

This example defines a new value named log pointing to Console.WriteLine, then executes a script calling log('Hello World!').

var engine = new Engine()
    .SetValue("log", new Action<object>(Console.WriteLine))
    ;

engine.Execute(@"
  function hello() { 
    log("Hello World");
  };

  hello();
");

Here, the variable x is set to 3 and x * x is executed in JavaScript. The result is returned to .NET directly, in this case as a double value 9.

var square = new Engine()
    .SetValue("x", 3)
    .Execute("x * x")
    .ToObject()
    ;

You can also directly pass POCOs or anonymous objects and use them from JavaScript. In this example for instance a new Person instance is manipulated from JavaScript.

var p = new Person {
    Name = "Mickey Mouse"
};

var engine = new Engine()
    .SetValue("p", p)
    .Execute("p.Name === 'Mickey Mouse')
    ;

Roadmap

Status:

TODO:

  • Improve C# interoperability
  • Fix remaining unit tests
    • Regular expression (15.10)
    • Error object (15.11)
    • Object constructor (15.2.3)
    • Object prototype (15.2.4)