refactoring

This commit is contained in:
sanex3339
2016-05-20 14:53:26 +03:00
parent 28f2622e9a
commit f66eeda8d2
3 changed files with 14 additions and 9 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ export abstract class NodeObfuscator implements INodeObfuscator {
*/
protected replaceLiteralStringByArrayElement (nodeValue: string): string {
let value: string = Utils.stringToUnicode(nodeValue),
unicodeArray = this.nodes.get('unicodeArrayNode').getNodeData(),
unicodeArray: string[] = this.nodes.get('unicodeArrayNode').getNodeData(),
sameIndex: number = unicodeArray.indexOf(value),
index: number;
@@ -39,9 +39,12 @@ class VariableDeclarationObfuscator extends NodeObfuscator_1.NodeObfuscator {
let isNodeAfterVariableDeclaratorFlag = false;
estraverse.replace(scopeNode, {
enter: (node, parentNode) => {
if (node.type === 'FunctionDeclaration' ||
node.type === 'FunctionExpression' ||
node.type === 'ArrowFunctionExpression') {
const functionNodes = [
'ArrowFunctionExpression',
'FunctionDeclaration',
'FunctionExpression'
];
if (functionNodes.indexOf(node.type) >= 0) {
estraverse.replace(node, {
enter: (node, parentNode) => {
this.replaceNodeIdentifierByNewValue(node, parentNode, this.variableNames);
@@ -76,11 +76,13 @@ export class VariableDeclarationObfuscator extends NodeObfuscator {
estraverse.replace(scopeNode, {
enter: (node: ITreeNode, parentNode: ITreeNode) => {
if (
node.type === 'FunctionDeclaration' ||
node.type === 'FunctionExpression' ||
node.type === 'ArrowFunctionExpression'
) {
const functionNodes: string[] = [
'ArrowFunctionExpression',
'FunctionDeclaration',
'FunctionExpression'
];
if (functionNodes.indexOf(node.type) >= 0) {
estraverse.replace(node, {
enter: (node: ITreeNode, parentNode: ITreeNode) => {
this.replaceNodeIdentifierByNewValue(node, parentNode, this.variableNames);