sm.js
Run a SpiderMonkey shell as a node child process.
Usage
var SM = ; var sm = shell: "js" ; sm;sm;sm;sm;sm;sm;sm;sm;sm; // request the end of sessionsm;
Constructor
This module is a constructor with a single options object that recognizes one option:
shell="js"
: the path to the SpiderMonkey shell
Methods
The result of the constructor is an EventEmitter object with the following methods:
eval(src, callback)
: evaluates source with SpiderMonkeyload(path, callback)
: evaluates source from a file with SpiderMonkeyparse(src, callback)
: parses source with SpiderMonkeyparseFile(path, callback)
: parses contents of a file with SpiderMonkeycheck(src, callback)
: checks source for valid syntax with SpiderMonkeycheckFile(path, callback)
: checks source from a file for valid syntax with SpiderMonkeyclose
: sends a message requesting SpiderMonkey to close down after finishing all pending actions
Each method sends a buffered message to SpiderMonkey requesting that it evaluate the corresponding action.
Each callback takes an error object signifying that SpiderMonkey threw an exception or an error occurred communicating with SpiderMonkey, or null
followed by a return value if the action returned normally.
Events
"message"
: received a response from the SpiderMonkey shell"exit"
: the SpiderMonkey shell has exited
License
Copyright © 2012 Dave Herman
Licensed under the MIT License.