Giter Site home page Giter Site logo

erlang-mozjs / erlang-mozjs Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 6.0 3.7 MB

A NIF module for Erlang to Mozilla's Spidermonkey Javascript runtime.

License: Apache License 2.0

Makefile 0.97% C++ 26.71% JavaScript 32.30% Erlang 34.56% Dockerfile 5.46%
erlang javascript js nif spidermonkey

erlang-mozjs's Introduction

erlang-mozjs

Overview

Travis-CI :: https://secure.travis-ci.org/erlang-mozjs/erlang-mozjs.png

erlang-mozjs is a NIF library, and API that embeds Mozilla’s Spidermonkey Javascript Virtual Machine in Erlang. Originally created to facilitate usage of Riak’s MapReduce by non-Erlang programmers, it supports multiple concurrent Javascript VMs, runtime evaluation of Javascript code, and invocation of Javascript functions.

erlang-mozjs builds and executes only on Unix-based platforms, including Linux, Mac OS/X, and Solaris. It requires Spidermonkey 52 and includes Douglas Crockford’s json2.js JSON parser. More information about the features available to Javascript inside erlang-mozjs are detailed on the Mozilla Developer Center.

Quick Start

You must have Erlang/OTP 18 or later and a GNU-style make system to compile and run erlang-mozjs.

git clone git://github.com/erlang-mozjs/erlang-mozjs.git
make all test

Start up an Erlang shell with the path to erlang-mozjs included.

erl -pa path/to/erlang-mozjs/ebin -boot start_sasl

Create a Javascript VM.

1> {ok, JS} = js_driver:new().
{ok,#Ref<0.557298074.1409679362.105432>}

Now you can evaluate Javascript expressions and call Javascript functions.

2> js:define(JS, <<"var addOne = function(a){ return a + 1; }">>).
ok
3> js:call(JS, <<"addOne">>, [3]).
{ok,4}

Release JS resource when no longer needed.

4> js_driver:destroy(JS).
ok

Documentation

Documentation about the API is extensive and can be generated by edoc.

$ make docs
$ open docs/index.html

Contributing

We encourage contributions to erlang-mozjs from the community.

  1. Fork the erlang-mozjs repository on Github.
  2. Clone your fork or add the remote if you already have a clone of the repository.
git clone [email protected]:yourusername/erlang-mozjs.git
# or
git remote add mine [email protected]:yourusername/erlang-mozjs.git
  1. Create a topic branch for your change.
git checkout -b some-topic-branch
  1. Make your change and commit. Use a clear and descriptive commit message, spanning multiple lines if detailed explanation is needed.
  2. Push to your fork of the repository and then send a pull-request through Github.
git push mine some-topic-branch
  1. A community maintainer will review your patch and merge it into the main repository or send you feedback.

erlang-mozjs's People

Contributors

argv0 avatar beerriot avatar borshop avatar cmeiklejohn avatar cristianberneanu avatar dantealiegri avatar dizzyd avatar dreverri avatar frantisekz avatar jadeallenx avatar jaredmorrow avatar jonmeredith avatar jtuple avatar kellymclaughlin avatar kuenishi avatar lemenkov avatar marianoguerra avatar mokele avatar msantos avatar pichi avatar seancribbs avatar slfritchie avatar stransky avatar vagabond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

erlang-mozjs's Issues

Consider rebase to a newer mozjs?

Would it be possible to get this package from a long-obsolete mozjs68 to a newer version? mozjs102 is the latest and would be ideal!

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.