npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodeschnaps

v0.12.0

Published

A NodeJS compatibility layer for Java (Rhino).

Downloads

59

Readme

Nodeschnaps

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.

Travis npm npm

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

load('./node_modules/nodeschnaps/loader.js');

// Your code here ...

NodeJS();

Pentaho Data-Integration (Kettle)

Load on Transformation (Modified Java Script Value):

Start Script

LoadScriptFile(getEnvironmentVar('NODESCHNAPS_LOADER_FILE'));

// Your code here ...

NodeJS();

Transform Script


// Your code here ...

NodeJS();

End Script

// Your code here ...

NodeJS();
Load on Job (JavaScript):
new Function(
    org.apache.commons.io.FileUtils.readFileToString(
      new java.io.File(parent_job.getVariable('NODESCHNAPS_LOADER_FILE'))
    )
)();

// Your code here ...

NodeJS();

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:

NodeJS(function(){
    // Your code here ...
});

Or before:

// Your code here ...

NodeJS();