0.0.1 • Published 11 years ago
scriptsplugger v0.0.1
node-hot_scripts_plugger
This node module lets you load and manage scripts that can be read from the code as well as from a file system.
API
The API can be found under this directory and this one for MD format.
How to use.
var ScriptsPlugger = require('scriptsplugger');
var myScripts = new ScriptsPlugger();
// Function to add
var myFunction = function () {
console.log('Hello World');
};
myScripts.addScript('helloWorld', myFunction);
// Let's imagine that a JavaScript function is writen under *scripts/goodbye.js*
myScripts.addScript('goodbye', 'scripts/goodbye.js');
myScripts.call('helloWorld'); // Print 'Hello World'
myScripts.call('goodbye'); // Execute what is defined in the read file
// Scripts can be called with how many arguments as wished
var fn = function (a, b) {
return (a + b);
};
myScripts.add('add', fn);
var result = myScripts.call('add', 4, 5);
console.log(result); // '9'
Scripts read from file
Concerning the scripts added from the file system, please respect the following format:
function (arg1, arg2, arg3) {
// The code
}
You are free to do whatever you want into the function. The only requirement is to define a function your script as a JavaScript anonymous function.
Your scripts will be executed by node, and so, you can feel free to use node modules.
0.0.1
11 years ago