Skip to content
Embedded JavaScript Engine for R
Branch: master
Clone or download
Latest commit 9914999 Apr 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Fix build for 7.3.492.22 (#55) Mar 16, 2019
inst/js Cleanup Feb 7, 2019
man Fix build for 7.3.492.22 (#55) Mar 16, 2019
old remove references to new_context() Mar 27, 2016
src [WIP] api changes for v8 version 7.4 (#57) Apr 9, 2019
tests Print engine version during CMD check Mar 16, 2019
tools Remove workaround Feb 7, 2019
vignettes Spelling Feb 7, 2019
.Rbuildignore Ignore revdep Jul 16, 2016
.gitignore
.travis.yml Trigger build Feb 19, 2019
DESCRIPTION bump version for release Apr 13, 2019
LICENSE Use safe syntax Mar 17, 2017
NAMESPACE Upgrade to new V8 api (#50) Feb 6, 2019
NEWS Update NEWS Apr 9, 2019
README.md Update readme Feb 14, 2019
V8.Rproj EOL fix Dec 4, 2014
appveyor.yml Add appveyor Apr 1, 2016
cleanup add cleanup script Dec 14, 2016
configure Fix build on MacOS Mar 26, 2019
configure.win copy files from old repo Dec 4, 2014

README.md

V8

Embedded JavaScript Engine for R

Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge CRAN RStudio mirror downloads

An R interface to Google's open source JavaScript engine. This package can now be compiled either with V8 version 6 (LTS) from nodejs or with the legacy 3.14/3.15 version of V8.

Documentation

About the R package:

Hello World

# Create a new context
library(V8)
ctx <- v8()

# Evaluate some code
ctx$eval("var foo = 123")
ctx$eval("var bar = 456")
ctx$eval("foo+bar")

# Assign / get objects
ctx$assign("foo", JS("function(x){return x*x}"))
ctx$assign("bar", JS("foo(9)"))
ctx$get("bar")

Call functions from JavaScript libraries

ctx <- V8::v8()
ctx$source("https://cdnjs.cloudflare.com/ajax/libs/coffee-script/1.4.0/coffee-script.min.js")
jscode <- ctx$call("CoffeeScript.compile", "square = (x) -> x * x", list(bare = TRUE))
ctx$eval(jscode)
ctx$call("square", 9)

Installation

Binary packages for OS-X or Windows can be installed directly from CRAN:

install.packages("V8")

Installation from source on Linux requires libv8. On Ubuntu / Debian you need to install libv8-dev. On Debian 10 / Ubuntu 19.04 and up, libv8-dev is actually provided by libnode, but the installation remains the same:

# Debian and Ubuntu
sudo apt-get install -y libv8-dev

On Fedora we need v8-devel:

sudo yum install v8-devel

On CentOS / RHEL we install v8-devel via EPEL:

sudo yum install epel-release
sudo yum install v8-devel

On OS-X use v8 from Homebrew:

brew install v8

On other systems you might need to install libv8 from source.

You can’t perform that action at this time.