function funcWithReturnFromSnippet(js) {
    // auto-"return"
    if (js.indexOf('return') === -1) {
        if (js.substring(js.length - 1) === ';') {
            js = js.substring(0, js.length - 1);
        }
        js = 'return (' + js + ')';
    }

    // Expose level definitions to condition func context
    var varDefs = [];
    Object.keys(upperNameFromLevel).forEach(function (lvl) {
        varDefs.push(format('var %s = %d;',
                upperNameFromLevel[lvl], lvl));
    });
    varDefs = varDefs.join('\n') + '\n';

    return (new Function(varDefs + js));
}
function funcWithReturnFromSnippet(js) {
    
    if (js.indexOf('return') === -1) {
        if (js.substring(js.length - 1) === ';') {
            js = js.substring(0, js.length - 1);
        }
        js = 'return (' + js + ')';
    }

    
    var varDefs = [];
    Object.keys(upperNameFromLevel).forEach(function (lvl) {
        varDefs.push(format('var %s = %d;',
                upperNameFromLevel[lvl], lvl));
    });
    varDefs = varDefs.join('\n') + '\n';

    return (new Function(varDefs + js));
}
function funcWithReturnFromSnippet ( js ) { // auto-"return" if ( js . indexOf ( 'return' ) === - 1 ) { if ( js . substring ( js . length - 1 ) === ';' ) { js = js . substring ( 0 , js . length - 1 ) ; } js = 'return (' + js + ')' ; } // Expose level definitions to condition func context var varDefs = [ ] ; Object . keys ( upperNameFromLevel ) . forEach ( function ( lvl ) { varDefs . push ( format ( 'var %s = %d;' , upperNameFromLevel [ lvl ] , lvl ) ) ; } ) ; varDefs = varDefs . join ( '\n' ) + '\n' ; return ( new Function ( varDefs + js ) ) ; }
Return a function for the given JS code that returns.

If no 'return' in the given javascript snippet, then assume we are a single
statement and wrap in 'return (...)'. This is for convenience for short
'-c ...' snippets.
Return a function for the given JS code that returns .