src/eva.js
function createFunction(sCode, settings) {
    /*jshint evil:true, laxbreak:true, quotmark:false*/
    var nI, params, sName;
    if (! settings) {
        settings = {};
    }
    params = settings.paramNames;
    if (settings.expression) {
        sCode = "return (" + sCode + ");";
    }
    if (settings.scope) {
        if (params) {
            nI = params.indexOf(",");
            if (nI > -1) {
                sName = params.substring(0, nI);
            }
            else {
                sName = params;
            }
        }
        else {
            params = sName = "sc";
        }
        sCode = "with(" + sName + ") {" + sCode + "}";
    }
    if (settings.debug && (settings.debugFunc 
                            || (typeof console === "object" && console && typeof console.log === "function"))) {
        sCode = 'try{'
                    + sCode
                    + '}catch(_e_){'
                    + (settings.debugFunc || 'console.log')
                    + '("'
                    + (settings.debugMessage
                            ? settings.debugMessage.replace(/"/g, '\\\"')
                            : 'Error in created function:')
                    + '", _e_);}';
    }
    return params ? new Function(params, sCode) : new Function(sCode);
}
function createFunction(sCode, settings) {
    /*jshint evil:true, laxbreak:true, quotmark:false*/
    var nI, params, sName;
    if (! settings) {
        settings = {};
    }
    params = settings.paramNames;
    if (settings.expression) {
        sCode = "return (" + sCode + ");";
    }
    if (settings.scope) {
        if (params) {
            nI = params.indexOf(",");
            if (nI > -1) {
                sName = params.substring(0, nI);
            }
            else {
                sName = params;
            }
        }
        else {
            params = sName = "sc";
        }
        sCode = "with(" + sName + ") {" + sCode + "}";
    }
    if (settings.debug && (settings.debugFunc 
                            || (typeof console === "object" && console && typeof console.log === "function"))) {
        sCode = 'try{'
                    + sCode
                    + '}catch(_e_){'
                    + (settings.debugFunc || 'console.log')
                    + '("'
                    + (settings.debugMessage
                            ? settings.debugMessage.replace(/"/g, '\\\"')
                            : 'Error in created function:')
                    + '", _e_);}';
    }
    return params ? new Function(params, sCode) : new Function(sCode);
}
function createFunction ( sCode , settings ) { /*jshint evil:true, laxbreak:true, quotmark:false*/ var nI , params , sName ; if ( ! settings ) { settings = { } ; } params = settings . paramNames ; if ( settings . expression ) { sCode = "return (" + sCode + ");" ; } if ( settings . scope ) { if ( params ) { nI = params . indexOf ( "," ) ; if ( nI > - 1 ) { sName = params . substring ( 0 , nI ) ; } else { sName = params ; } } else { params = sName = "sc" ; } sCode = "with(" + sName + ") {" + sCode + "}" ; } if ( settings . debug && ( settings . debugFunc || ( typeof console === "object" && console && typeof console . log === "function" ) ) ) { sCode = 'try{' + sCode + '}catch(_e_){' + ( settings . debugFunc || 'console.log' ) + '("' + ( settings . debugMessage ? settings . debugMessage . replace ( / " / g , '\\\"' ) : 'Error in created function:' ) + '", _e_);}' ; } return params ? new Function ( params , sCode ) : new Function ( sCode ) ; }
Create function to further use.

@param {String} sCode
Function's code.
@param {Object} [settings]
Operation settings. Keys are settings names, values are corresponding settings values.
The following settings are supported (setting's default value is specified in parentheses):

* `debug`: `Boolean` (`false`) - specifies whether simple means for debugging should be added into function;
when `true` value is specified (debug mode), the function's code is enclosed in `try` statement;
the corresponding `catch` block contains `console.log` statement to display message
(namely, value of `debugMessage` setting) and details about error
* `debugFunc`: `String` (`console.log`) - expression specifying a function that should be used to process error
when the error is caught in debug mode; the expression should be resolvable in global scope;
debug message (value of `debugMessage` setting) and error object will be passed into the function
* `debugMessage`: `String` (`Error in created function:`) - specifies message that should be shown/passed
before data about error when the error is caught in debug mode
* `expression`: `Boolean` (`false`) - specifies whether function's code is an expression;
when `true` value is specified, `return` statement is added at the beginning of function's code
* `paramNames`: `String` (`''`) - specifies names of function parameters
* `scope`: `Boolean` (`false`) - specifies whether function's code should be wrapped in `with` statement;
the value of function's first parameter is used as expression for `with` statement
@return {Function}
Created function.
@alias module:eva.createFunction
Create function to further use .