How to use the escodegen/node_modules/estraverse.VisitorKeys function in escodegen

To help you get started, we’ve selected a few escodegen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github probmods / webchurch / wctransform.js View on Github external
leave: function(node)
        {

            //get call to be moved up from children:
            var callsToMove = []
            var candidates = estraverse.VisitorKeys[node.type]
            for(var c in candidates) {
                var candidate = node[candidates[c]]
                if(!candidate){break}
                if(candidate instanceof Array) {
                    for(var i in candidate){callsToMove = callsToMove.concat(candidate[i].callsToMove || [])}
                } else {
                    callsToMove = callsToMove.concat(candidate.callsToMove || [])
                }
            }

            //transform calls (which could be in args) by replacing with new identifier, wrapping with enter/leave marks, and adding to queue to move up.
            if(!node.skipcall && node.type == 'CallExpression') {
                //replace with new identifier, add to call queue.
                var id = nextid++
                var idNode = {type: "Identifier", name: "call"+id}
                idToFunctionName[id + ""] = node.callee.name;
github probmods / webchurch / src / wctransform.js View on Github external
leave: function(node)
        {

          //get call to be moved up from children:
          var callsToMove = [];
          var candidates = estraverse.VisitorKeys[node.type];
          for (var c in candidates) {
            var candidate = node[candidates[c]];
            if (!candidate) {break}
            if (candidate instanceof Array) {
              for (var i in candidate) {callsToMove = callsToMove.concat(candidate[i].callsToMove || [])}
            } else {
              callsToMove = callsToMove.concat(candidate.callsToMove || []);
            }
          }

          //transform calls (which could be in args) by replacing with new identifier, wrapping with enter/leave marks, and adding to queue to move up.
          if (!node.skipcall && node.type == 'CallExpression') {
            //replace with new identifier, add to call queue.
            var id = nextid++;
            var idNode = {type: 'Identifier', name: 'call' + id};
            idToFunctionName[id + ''] = node.callee.name;