How to use the isFunctionDeclaration function from @babel/types
Find comprehensive JavaScript @babel/types.isFunctionDeclaration code examples handpicked from public code repositorys.
GitHub: yandex/reselector
84 85 86 87 88 89 90 91 92 93
isComponent = isComponent || ( t.isArrowFunctionExpression(node) || t.isFunctionExpression(node) || t.isClassMethod(node) || t.isObjectMethod(node) || t.isFunctionDeclaration(node) ) if (!componentNode && isComponent) { componentNode = node
10
44
10
+ 17 other calls in file
143 144 145 146 147 148 149 150 151 152
let local; if (t.isIdentifier(declaration)) { local = declaration.name; } else if ( t.isFunctionDeclaration(declaration) || t.isClassDeclaration(declaration) ) { if (declaration.id) { local = declaration.id.name;
6
34
0
+ 7 other calls in file
46 47 48 49 50 51 52 53 54 55
}, ExportDefaultDeclaration: (path) => { const { declaration } = path.node; // insert `export default ${identifier}(module)(xxx)` if (t.isClassDeclaration(declaration) || t.isFunctionDeclaration(declaration)) { if (t.isIdentifier(declaration.id)) { path.replaceWith(declaration); insertNodes.push( t.ExportDefaultDeclaration(
1
5
0
100 101 102 103 104 105 106 107 108 109
types.isBlockStatement(node) || types.isBlock(node) ) { return node.body.some(statement => hasBinding(statement, name)); } else if ( types.isFunctionDeclaration(node) || types.isFunctionExpression(node) || types.isArrowFunctionExpression(node) ) { return (
0
2
2
+ 3 other calls in file
201 202 203 204 205 206 207 208 209 210
scope } = path; if (t.isExportAllDeclaration(node)) return; const declar = node.declaration; if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) { const id = declar.id; if (!id) return; const binding = scope.getBinding(id.name); if (binding) binding.reference(path);
0
1
1
+ 16 other calls in file
GitHub: Blue-Skie/YuanRenXue-Web
516 517 518 519 520 521 522 523 524 525
} }, FunctionDeclaration(path) { let {body} = path.node.body; if (body.length == 2 && types.isFunctionDeclaration(body[0]) && types.isTryStatement(body[1])) { let sourceCode = path.toString(); if (sourceCode.includes("constructor") &&
0
0
1
+ 71 other calls in file
15 16 17 18 19 20 21 22 23 24
* 函数表达式 * 方法 * 则返回 true * **/ const isAsyncFuncNode = node => t.isFunctionDeclaration(node, { async: true }) || t.isArrowFunctionExpression(node, { async: true
0
0
0
513 514 515 516 517 518 519 520 521 522
var componentBlock = getParentComponentOrUseFuncBlock(path); var childToPut = types.cloneNode(transformedPath.node); // console.log(path.parent); // console.log(transformedPath.node); // if (typeExp === "DECLARE") { if (typeExp === "DECLARE" && types.isFunctionDeclaration(path.node)) { childToPut = types.callExpression(types.identifier(path.node.id.name), initAnnotationParser(immidateTopComment.value)); } if (typeExp === "DECLARE" && types.isVariableDeclaration(path.node) && (types.isArrowFunctionExpression(path.node.declarations[0].init) || types.isFunctionExpression(path.node.declarations[0].init))) {
0
0
1
@babel/types.identifier is the most popular function in @babel/types (20936 examples)