mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
tests and refactoring
This commit is contained in:
+6
-2
@@ -51,11 +51,15 @@ export class NodeUtils {
|
||||
* @returns {INode}
|
||||
*/
|
||||
public static getBlockStatementNodeByIndex (node: INode, index: number = 0): INode {
|
||||
if (Nodes.isNodeHasBlockStatement(node) && node.body[index]) {
|
||||
if (Nodes.isNodeHasBlockStatement(node)) {
|
||||
if (node.body[index] === undefined) {
|
||||
throw new ReferenceError(`Wrong index \`${index}\`. BlockStatement body length is \`${node.body.length}\`.`);
|
||||
}
|
||||
|
||||
return node.body[index];
|
||||
}
|
||||
|
||||
return node;
|
||||
throw new TypeError('The specified node has not block statement');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user