I don't have an example, just an idea.
You may execute your JS with node.js on command line (over $ZF or a CommandPipe) and collect the result yourself or
by Using Node.js with Caché. with direct object access.
I've seen something here: