Nodeschnaps is a node.js compatibility layer for Java Javscript engines like Rhino. The main inspiration is to run ETL transformation with the same code we use in node.js to save development time.
Features
We work hard to implement the full API of node.js. So you could load Nodeschnaps into your Rhino environment and use your node.js code without restrictions. Take a look at the current development status to get a overview of what we done so far.
Supported Platforms
- Rhino JS
- Pentaho Data-Integration (Kettle)
- Nashorn
- Pentaho Data-Integration (Kettle)
Installation
npm install nodeschnaps
Testing
Install dev dependencies:
npm install
Run tests with rhinojs:
make test
Run tests with nodejs:
make testNode
Configuration
Environment Variables
NODESCHNAPS_PATH
(required)
Path to search for modules/files (Last must be the nodeschnaps lib folder).
One path of the variable must be set to the lib folder of nodeschnaps. The path separator is like in the other path variables ":".
Nodeschnaps need to know his location to load his own modules.
The paths should be absolute to be independent from applications CWD like in the case of Kettle.
Example:
/home/you/project/node_modules:/home/you/project/node_modules/nodeschnaps/lib
NODESCHNAPS_MODIFIER
(optional)
A path to a module, what will be loaded at the start to modify the environment.
Load nodeschnaps
To load nodeschnaps the environment variable NODESCHNAPS_PATH must be set.
Optional you can use for rhino the includet rhino jar in the deps/rhino/lib folder.
Example for rhino:
java \ -cp ./node_modules/nodeschnaps/deps/rhino/lib/rhino-1.7.11.jar \ -DNODESCHNAPS_PATH=/home/you/project/node_modules/nodeschnaps/lib \ org.mozilla.javascript.tools.shell.Main \ test.js
Rhino JS / Nashorn
; // Your code here ... ;
Pentaho Data-Integration (Kettle)
Load on Transformation (Modified Java Script Value):
Start Script
; // Your code here ... ;
Transform Script
// Your code here ... ;
End Script
// Your code here ... ;
Load on Job (JavaScript):
orgapachecommonsioFileUtils; // Your code here ... ;
For a example look at: kitchen-stove
Start from Command-line
Rhino
java \ -DNODESCHNAPS_PATH=./node_modules/nodeschnaps/lib \ -cp ./node_modules/nodeschnaps/deps/rhino/lib/rhino-1.7.11.jar \ org.mozilla.javascript.tools.shell.Main \ YOUR.js
Nashorn
jjs \ --language=es5 \ -DNODESCHNAPS_PATH=./node_modules/nodeschnaps/lib \ YOUR.js
Coding
Start main loop
As callback:
;
Or before:
// Your code here ... ;