Skip to content

Lampese/NocturneJS

Repository files navigation

NocturneJS

QuickJS-aligned JavaScript runtime in MoonBit.

Usage

Run a single JavaScript file:

moon run --target native --release cmd/main -- path/to/file.js

Library usage (MoonBit):

moon add Lampese/nocturnejs
{
  "import": [
    {
      "path": "Lampese/nocturnejs",
      "alias": "njs"
    }
  ]
}
let engine = @njs.Engine::new()
let result = engine.eval_result("1 + 2") catch {
  err => {
    println("error: \{err}")
    return
  }
}
match result {
  Ok(value) => println(engine.value_to_string(value))
  Err(err) => println("error: \{engine.format_error(err)}")
}

Testing

Run test262 with the QuickJS-aligned config:

moon update
git submodule update --init --recursive
git -C test262 apply --check ../test262-config/test262.patch && \
git -C test262 apply ../test262-config/test262.patch
moon run --target native --release cmd/test262 -- -c test262-config/test262.conf

Test262 Coverage

NJS NocturneJS test262: 43,616 passed, 49 failed, 5,767 skipped pass 43,616 (88.23%) fail 49 (0.10%) skipped 5,767 (11.67%) excluded 2,567 (not shown)
QJS QuickJS test262: 43,606 passed, 52 failed, 5,767 skipped pass 43,606 (88.23%) fail 52 (0.11%) skipped 5,767 (11.67%) excluded 2,567 (not shown)

* Total differs by 7 tests because QuickJS data comes from a historical report snapshot, while we enumerate the current test262 directory.

About

A small, spec-compliant JavaScript engine written in MoonBit, inspired by QuickJS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors