mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added ability to add specific node guard to the black list of nodes.
This nodes wont obfuscated.
This commit is contained in:
+24
-8
@@ -146,6 +146,22 @@ export class Node {
|
||||
return node.type === NodeType.MethodDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} object
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public static isNode (object: Object & { type?: string }): object is ESTree.Node {
|
||||
return object && !object.type !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public static isNodeHasBlockStatement (node: ESTree.Node): node is TNodeWithBlockStatement {
|
||||
return Array.isArray((<TNodeWithBlockStatement>node).body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
@@ -214,6 +230,14 @@ export class Node {
|
||||
return node.type === NodeType.UnaryExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public static isUseStrictOperator (node: ESTree.Node): node is ESTree.ExpressionStatement {
|
||||
return node.type === NodeType.ExpressionStatement && node.directive === 'use strict';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
@@ -229,12 +253,4 @@ export class Node {
|
||||
public static isVariableDeclaratorNode (node: ESTree.Node): node is ESTree.VariableDeclarator {
|
||||
return node.type === NodeType.VariableDeclarator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public static isNodeHasBlockStatement (node: ESTree.Node): node is TNodeWithBlockStatement {
|
||||
return node.hasOwnProperty('body') && Array.isArray((<TNodeWithBlockStatement>node).body);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user