Skip to content

Commit

Permalink
add getIIFE utility
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff committed May 9, 2018
1 parent 3fcc6d8 commit 139f75a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions util/util.ts
Expand Up @@ -1179,3 +1179,10 @@ export function isAmbientModuleBlock(node: ts.Node): node is ts.ModuleBlock {
}
return false;
}

export function getIIFE(func: ts.FunctionExpression | ts.ArrowFunction): ts.CallExpression | undefined {
let node = func.parent!;
while (node.kind === ts.SyntaxKind.ParenthesizedExpression)
node = node.parent!;
return isCallExpression(node) && func.end <= node.expression.end ? node : undefined;
}

0 comments on commit 139f75a

Please sign in to comment.