8000 GitHub - nateabele/jsengine: Embedded JavaScript runtime for Elixir
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nateabele/jsengine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSEngine: An embedded JavaScript runtime for Elixir

Run JavaScript code, right inside Elixir. Just like this:

> JSEngine.load(["/path/to/file.js"]);
{:ok, nil}
> JSEngine.run("function add(a, b) { return a + b; }")
{:ok, nil}
> JSEngine.call("add", [1, 2])
{:ok, 3}

Why?

There are a couple other JS-in-Elixir libraries, but either they're just wrappers around IPC that serialize your function calls into files, or else they have weird edge cases and issues compiling.

This version is implemented in Rust on top of Deno Core, so it's modern, reliable, safe, and fast—and lives fully within the BEAM.

Features

  • Converts JS values to Elixir terms
  • Converts function arguments passed in call from Elixir terms to JS values
  • Automatically unwraps promises

Roadmap

Because Deno Core has so much packed in, lots more features are within easy reach.

  • Module loading: Right now, load() just executes single self-contained JS files. With module-loading, it's possible to load an ES module that imports dependencies, and have those dependencies loaded automatically.
  • TypeScript support: Automatically load and resolve TypeScript files—no build step required.
  • Multiple environments: Right now, a single JavaScript environment (v8::Isolate) is supported, but multiple independent environments could be supported.

Installation

If available in Hex, the package can be installed by adding jsengine to your list of dependencies in mix.exs:

def deps do
  [
    {:jsengine, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/jsengine.

About

Embedded JavaScript runtime for Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0