tests and refactoring

This commit is contained in:
sanex3339
2016-06-17 16:55:28 +03:00
parent 9eb172a19e
commit 320719360c
3 changed files with 20 additions and 9 deletions
+6 -2
View File
@@ -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');
}
/**