Browse Source

refactoring

sanex3339 9 years ago
parent
commit
0735f57771

+ 4 - 4
dist/index.js

@@ -1870,7 +1870,7 @@ module.exports =
 	        value: function replaceCatchClauseParam(catchClauseNode) {
 	            var _this2 = this;
 	
-	            estraverse.replace(catchClauseNode.param, {
+	            estraverse.traverse(catchClauseNode.param, {
 	                leave: function leave(node) {
 	                    return _this2.storeIdentifiersNames(node, _this2.catchClauseParam);
 	                }
@@ -1946,7 +1946,7 @@ module.exports =
 	        value: function replaceFunctionName(functionDeclarationNode) {
 	            var _this2 = this;
 	
-	            estraverse.replace(functionDeclarationNode.id, {
+	            estraverse.traverse(functionDeclarationNode.id, {
 	                leave: function leave(node) {
 	                    return _this2.storeIdentifiersNames(node, _this2.functionName);
 	                }
@@ -2019,7 +2019,7 @@ module.exports =
 	            var _this2 = this;
 	
 	            functionNode.params.forEach(function (paramsNode) {
-	                estraverse.replace(paramsNode, {
+	                estraverse.traverse(paramsNode, {
 	                    leave: function leave(node) {
 	                        return _this2.storeIdentifiersNames(node, _this2.functionParams);
 	                    }
@@ -2414,7 +2414,7 @@ module.exports =
 	            var _this2 = this;
 	
 	            variableDeclarationNode.declarations.forEach(function (declarationNode) {
-	                estraverse.replace(declarationNode.id, {
+	                estraverse.traverse(declarationNode.id, {
 	                    enter: function enter(node) {
 	                        return _this2.storeIdentifiersNames(node, _this2.variableNames);
 	                    }

+ 1 - 1
src/node-obfuscators/CatchClauseObfuscator.ts

@@ -34,7 +34,7 @@ export class CatchClauseObfuscator extends NodeObfuscator {
      * @param catchClauseNode
      */
     private replaceCatchClauseParam (catchClauseNode: ICatchClauseNode): void {
-        estraverse.replace(catchClauseNode.param, {
+        estraverse.traverse(catchClauseNode.param, {
             leave: (node: INode): any => this.storeIdentifiersNames(node, this.catchClauseParam)
         });
     }

+ 1 - 1
src/node-obfuscators/FunctionDeclarationObfuscator.ts

@@ -40,7 +40,7 @@ export class FunctionDeclarationObfuscator extends NodeObfuscator {
      * @param functionDeclarationNode
      */
     private replaceFunctionName (functionDeclarationNode: IFunctionDeclarationNode): void {
-        estraverse.replace(functionDeclarationNode.id, {
+        estraverse.traverse(functionDeclarationNode.id, {
             leave: (node: INode): any => this.storeIdentifiersNames(node, this.functionName)
         });
     }

+ 1 - 1
src/node-obfuscators/FunctionObfuscator.ts

@@ -35,7 +35,7 @@ export class FunctionObfuscator extends NodeObfuscator {
      */
     private replaceFunctionParams (functionNode: IFunctionNode): void {
         functionNode.params.forEach((paramsNode: INode) => {
-            estraverse.replace(paramsNode, {
+            estraverse.traverse(paramsNode, {
                 leave: (node: INode): any => this.storeIdentifiersNames(node, this.functionParams)
             });
         });

+ 5 - 4
src/node-obfuscators/VariableDeclarationObfuscator.ts

@@ -44,11 +44,12 @@ export class VariableDeclarationObfuscator extends NodeObfuscator {
      * @param variableDeclarationNode
      */
     private replaceVariableName (variableDeclarationNode: IVariableDeclarationNode): void {
-        variableDeclarationNode.declarations.forEach((declarationNode: IVariableDeclaratorNode) => {
-            estraverse.replace(declarationNode.id, {
-                enter: (node: INode): any => this.storeIdentifiersNames(node, this.variableNames)
+        variableDeclarationNode.declarations
+            .forEach((declarationNode: IVariableDeclaratorNode) => {
+                estraverse.traverse(declarationNode.id, {
+                    enter: (node: INode): any => this.storeIdentifiersNames(node, this.variableNames)
+                });
             });
-        });
     }
 
     /**