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

Sebastien Ros d162edaace Implementing date helpers 11 년 전
.nuget 9b18dabfed Adding missing nuget.exe 11 년 전
Jint d162edaace Implementing date helpers 11 년 전
Jint.Benchmark d2a5131df8 Enabling nuget package restore for CI 11 년 전
Jint.Repl 6fb1d4789d Implementing object interop 11 년 전
Jint.Tests 578c6014ce Implementing CLR method invocation 11 년 전
Jint.Tests.Ecma 9bf869722a Adding 15.3 & 15.5.5 to pass suite 11 년 전
Jint.Tests.Scaffolding b6d60818da Adding Ecma 262 tests 12 년 전
.gitignore 2dab8046d6 Scaffolding project vs. hand written classes 12 년 전
CREDITS.txt f53137698a Adding license information 11 년 전
Jint.sln d2a5131df8 Enabling nuget package restore for CI 11 년 전
LICENSE.txt f53137698a Adding license information 11 년 전
README.md 97024f6db8 Updating readme samples 11 년 전

README.md

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.

Build status

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
  • Finish up ECMAScript test suite
    • Regular expression (15.10)
    • Error object (15.11)
    • Object constructor (15.2.3)
    • Object prototype (15.2.4)
    • Function object (15.3)
    • String object (15.5.4 & 15.5.5) work in progress