tasks/lib/removeloggingcalls.js
function(rootNode) {
        // queue to compute de breadth first search
        var queue = [rootNode]; 
        var nodes = [rootNode];

        while (queue.length !== 0) {
            // fetch child nodes of the first node of the queue
            var currentNode = queue.shift();
            for (var property in currentNode) {
                // compute only non-inherited properties
                if (currentNode.hasOwnProperty(property)) { 
                    if (Array.isArray(currentNode[property])) {
                        var nodeArray = currentNode[property];
                        for (var i = 0, ii = nodeArray.length; i < ii; ++i) {
                            // enqueue only if it is a Node instance
                            if (nodeArray[i] instanceof rootNode.constructor) {
                                queue.push(nodeArray[i]);
                                nodes.push(nodeArray[i]);
                            }
                        }
                    } else
                        // enqueue only if it is a Node instance
                        if (currentNode[property] instanceof rootNode.constructor) { 
                            queue.push(currentNode[property]);
                            nodes.push(currentNode[property]);
                        }
                }
            }
        }
        return nodes;
    }
function(rootNode) {
        // queue to compute de breadth first search
        var queue = [rootNode]; 
        var nodes = [rootNode];

        while (queue.length !== 0) {
            // fetch child nodes of the first node of the queue
            var currentNode = queue.shift();
            for (var property in currentNode) {
                // compute only non-inherited properties
                if (currentNode.hasOwnProperty(property)) { 
                    if (Array.isArray(currentNode[property])) {
                        var nodeArray = currentNode[property];
                        for (var i = 0, ii = nodeArray.length; i < ii; ++i) {
                            // enqueue only if it is a Node instance
                            if (nodeArray[i] instanceof rootNode.constructor) {
                                queue.push(nodeArray[i]);
                                nodes.push(nodeArray[i]);
                            }
                        }
                    } else
                        // enqueue only if it is a Node instance
                        if (currentNode[property] instanceof rootNode.constructor) { 
                            queue.push(currentNode[property]);
                            nodes.push(currentNode[property]);
                        }
                }
            }
        }
        return nodes;
    }
function ( rootNode ) { // queue to compute de breadth first search var queue = [ rootNode ] ; var nodes = [ rootNode ] ; while ( queue . length !== 0 ) { // fetch child nodes of the first node of the queue var currentNode = queue . shift ( ) ; for ( var property in currentNode ) { // compute only non-inherited properties if ( currentNode . hasOwnProperty ( property ) ) { if ( Array . isArray ( currentNode [ property ] ) ) { var nodeArray = currentNode [ property ] ; for ( var i = 0 , ii = nodeArray . length ; i < ii ; ++ i ) { // enqueue only if it is a Node instance if ( nodeArray [ i ] instanceof rootNode . constructor ) { queue . push ( nodeArray [ i ] ) ; nodes . push ( nodeArray [ i ] ) ; } } } else // enqueue only if it is a Node instance if ( currentNode [ property ] instanceof rootNode . constructor ) { queue . push ( currentNode [ property ] ) ; nodes . push ( currentNode [ property ] ) ; } } } } return nodes ; }
Compute the breadth first search on syntax tree to get the list of nodes
@param {Node} rootNode the root node of the tree
@return {Node[]} the list of all the tree nodes
Compute the breadth first search on syntax tree to get the list of nodes