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)
We plan to support the following platforms in the next time:
- Nashorn
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
Path to search for modules/files (Last must be the nodeschnaps lib folder).
NODESCHNAPS_MODIFIER
A path to a module, what will be loaded at the start to modify the environment.
Rhino JS
load('../loader.js');
NodeJS();
Pentaho Data-Integration (Kettle)
Load on Job (JavaScript):
new Function(
org.apache.commons.io.FileUtils.readFileToString(
new java.io.File(parent_job.getVariable('NODESCHNAPS_LOADER_FILE'))
)
)();
NodeJS();
Load on Transformation (Modified Java Script Value):
LoadScriptFile(getEnvironmentVar('NODESCHNAPS_LOADER_FILE'));
NodeJS();
For a example look at: kitchen-stove
Coding
Start main loop
As callback:
NodeJS(function(){
// Your code here ...
});
Or before:
// Your code here ...
NodeJS();