arboriculture.js
function transformForIn(node, path) {
        var label = node.$label;
        delete node.$label;
        var idx = ident(generateSymbol("idx"));
        var inArray = ident(generateSymbol("in"));
        var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
            inArray,node.right]).body;
        var loop = parsePart("for ($0; $1.length;){ $2 = $1.shift(); $:3 ; }", [node.left,
            inArray,node.left.type === 'VariableDeclaration' ? node.left.declarations[0].id : node.left,
            node.body]).body[0];
        loop.$label = label;
        for (var b = 0;b < path.length; b++) {
            if (examine(path[b].parent).isBlockStatement) {
                path[b].parent[path[b].field].splice(path[b].index, 0, declVars[0], declVars[1]);
                break;
            }
        }
        coerce(node, loop);
    }
function transformForIn(node, path) {
        var label = node.$label;
        delete node.$label;
        var idx = ident(generateSymbol("idx"));
        var inArray = ident(generateSymbol("in"));
        var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
            inArray,node.right]).body;
        var loop = parsePart("for ($0; $1.length;){ $2 = $1.shift(); $:3 ; }", [node.left,
            inArray,node.left.type === 'VariableDeclaration' ? node.left.declarations[0].id : node.left,
            node.body]).body[0];
        loop.$label = label;
        for (var b = 0;b < path.length; b++) {
            if (examine(path[b].parent).isBlockStatement) {
                path[b].parent[path[b].field].splice(path[b].index, 0, declVars[0], declVars[1]);
                break;
            }
        }
        coerce(node, loop);
    }
function transformForIn ( node , path ) { var label = node . $label ; delete node . $label ; var idx = ident ( generateSymbol ( "idx" ) ) ; var inArray = ident ( generateSymbol ( "in" ) ) ; var declVars = parsePart ( "var $0,$1 = [];for ($0 in $2) $1.push($0)" , [ idx , inArray , node . right ] ) . body ; var loop = parsePart ( "for ($0; $1.length;){ $2 = $1.shift(); $:3 ; }" , [ node . left , inArray , node . left . type === 'VariableDeclaration' ? node . left . declarations [ 0 ] . id : node . left , node . body ] ) . body [ 0 ] ; loop . $label = label ; for ( var b = 0 ; b < path . length ; b ++ ) { if ( examine ( path [ b ] . parent ) . isBlockStatement ) { path [ b ] . parent [ path [ b ] . field ] . splice ( path [ b ] . index , 0 , declVars [ 0 ] , declVars [ 1 ] ) ; break ; } } coerce ( node , loop ) ; }
Transform a for..in into it's iterative equivalent
Transform a for .. in into it s iterative equivalent