mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
refactoring
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user