rootJS
Node.js bindings for ROOT 6
Docs
Check this https://jenkins-rootjs.web.cern.ch/job/RootJS/doxygen/ for the current documentation. Documentation is generated by Jenkins, so this link should always point to a recent version.
Installation
rootJS is in the main npm package repository - all you have to do is have ROOT6 installed, then run npm install rootjs
.
Testing
Simply run npm test
after installing rootJS in development mode.
We currently use a mocha testsuite but might add something to (unit-)test C++ code directly.
Dependencies
- This module only supports Node.js v4.4 or newer
- You need to have ROOT-6.06.00 or newer installed (root-config needs to be available in your PATH)
- You need libuv, on Ubuntu you can use
sudo apt-get install libuv1-dev
to install it
Usage
You can use rootJS in a node shell by using require on the module directory, e.g.:
var root = ;
Afterwards you have access to root's functionality through the required root
object which copies its structure from ROOT.
> rootgProgName //You can access globals'node'> root //You can call global functions'compressthistext'> var browser = //You can create new objects (even GUI elements)undefined> browser //And run its methods'165781144'> browser'test'
Load libraries
You can easily load other ROOT libraries whenever needed, just use loadLibrary
:
>root //Loads math core0>rootROOTMath3141592653589793 //Verified!
Calling ROOT's gSystem.load("libName.so")
to load a library is highly discouraged and may result in unexpected behaviour.
If neccessary a refresh of the exported functions can be done through refreshExports
>root //Checks for additions to the gClassTable and exposes themundefined
Callbacks
We support async code execution on every method call, just add a callback:
> rootgSystem;>console;Async called // The second log is shown first because the other one will be called after "sleep 1"undefined> this is called in the callback
This will be usefull when processing huge amounts of data while setting up other parts of the environment.
Operators
C++ operators like "==" are supported, these operators are mapped on objects or in the global root object
> var t1 = "test"undefined> var t2 = "test"undefined> t1 == t2false> root // C++ == operatortrue > t1 //C++ []-operator'e' t1 //C++ ()-operator'st' t1 //C++ += operatorundefined> t1'test test2' //All implemented operators are prefixed with "_"