GithubHelp home page GithubHelp logo

systra / erlang_js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from basho/erlang_js

2.0 3.0 0.0 14.62 MB

A fork of linked-in driver for Erlang to Mozilla's Spidermonkey 1.8.5 Javascript runtime using Jiffy JSON Parser.

License: Apache License 2.0

Shell 0.32% C 35.65% Erlang 57.70% Makefile 6.33%

erlang_js's Introduction

erlang_js

Overview

erlang_js is a linked-in driver, API, and OTP application 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_js uses Jiffy JSON Parser for JSON encoding/decoding.

erlang_js builds and executes only on Unix-based platforms, including Linux, Mac OS/X, and Solaris (version with Spidermonkey 1.8.5 was tested on OS/X and Centos 6.3/6.5). More information about the features available to Javascript inside erlang_js are detailed on the Mozilla Developer Center.

Quick Start

You must have Erlang/OTP R13B04 or later and a GNU-style build system to compile and run erlang_js.

git clone git://github.com/systra/erlang_js.git
make all test

Start up an Erlang shell with the path to erlang_js included.

erl -pa ebin -pa deps/*/ebin -boot start_sasl

or using Make target

make run

Start the erlang_js application and create a Javascript VM.

1> application:start(erlang_js).

=PROGRESS REPORT==== 15-Oct-2012::22:09:39 ===
          supervisor: {local,erlang_js_sup}
             started: [{pid,<0.51.0>},
                       {name,cache},
                       {mfargs,{js_cache,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 15-Oct-2012::22:09:39 ===
         application: erlang_js
          started_at: nonode@nohost

ok
2> {ok, JS} = js_driver:new().
{ok,#Port<0.879>}

Now you can evaluate Javascript expressions and call Javascript functions.

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

Documentation

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

$ make docs
$ open docs/index.html

Coderwall :: http://api.coderwall.com/systra/endorse.png

erlang_js's People

Contributors

argv0 avatar beerriot avatar cmeiklejohn avatar cristianberneanu avatar dantealiegri avatar dizzyd avatar dreverri avatar jadeallenx avatar jaredmorrow avatar jonmeredith avatar jtuple avatar kellymclaughlin avatar kuenishi avatar lemenkov avatar mokele avatar msantos avatar seancribbs avatar slfritchie avatar systra avatar vagabond avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.