This module provides a class that reads a given directory in order to parse files supposed to contain javascript functions. Then, the object parses and evaluates all those functions, making them available for the developer. Also, the developer can, through this object, add functions will the process is running, and the added functions can be written to the filesystem also.

Hot Functions Manager

This module aims to read all files of a given directory in order to parse their content, supposed to be JavaScript functions. After being parsed, those functions will be available through a defined interface.

This module is available on NPM:

$ npm install hotfunctionsmanager

This module reads a given directory's files and evaluate their content. This content MUST be anonymous Javascript function. Those functions will be then available through a id-function interface, where the id of a function is its filename without extension.

For example, if there's a file "hello.js" that contains:

function () {
    console.log("Hello world!");

Then, the id of the function will be "hello".

It's on your own to write your functions with a correct syntax, unless the module will crash !

Let's consider that you have a directory "myDirectory", that contains two files: "hello.js" and "goodbye.js". So, you can do the following:

var HotFunctionsManager = require("hotFunctionsManager");
// Construct your object 
var myFunctions = new HotFunctionsManager("./myDirectory");
// Here, our object has been built, but our folder hasn't beed read yet 
// This is triggered by the call of the init() method. 
// Why ? Because, reading files involves I/O operations that may impact 
// considerably your application's performances. Please, consider it. 
// And now, you can call your functions 

Please, check this folder for the API.

Hot addition of functions is on the way ;-)