Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://raw.github.com/ariya/esprima/master/esprima.js"></script>
<script src="https://raw.github.com/freethenation/node-falafel/master/index.js"></script>
</head>
<body>
</body>
</html>
 
var src = '(' + function () {
    var xs = [ 1, 2, [ 3, 4 ] ];
    var ys = [ 5, 6 ];
    somefunc([ xs, ys ]);
} + ')();\n';
src += 'var g = [ 5, 6 ];';
var output = falafel(src, 
    function (node) {
        if (node.type === 'ArrayExpression' && !node.inFunc) {
            node.update('fn(' + node.source() + ')');
        }
    },
    function (node) {
        if (node.type === 'FunctionExpression') {
            node.inFunc = true;
        }
        else if (node.parent && node.parent.inFunc) {
            //inherit from parent
            node.inFunc = node.parent.inFunc;
        }
        else { node.inFunc = false; }
    });
console.log(output.toString());
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers