How to use the isArrowFunctionExpression function from @babel/types
Find comprehensive JavaScript @babel/types.isArrowFunctionExpression code examples handpicked from public code repositorys.
193 194 195 196 197 198 199 200 201 202
//如果data下面的变量为数组时,不遍历下面的内容,否则将会一一列出来 if (path.node.value && t.isArrayExpression(path.node.value)) path.skip(); } else { const node = path.node.value; if (t.isFunctionExpression(node) || t.isArrowFunctionExpression(node) || t.isObjectExpression(node)) { //这里function if (babelUtil.lifeCycleFunction[name]) { // console.log("add lifeCycle: ", name); vistors.lifeCycle.handle(path.node);
222
0
0
+ 15 other calls in file
GitHub: yandex/reselector
80 81 82 83 84 85 86 87 88 89
({ node, parentPath } = currentPath) if (parentPath && isElement(parentPath.node)) break isComponent = isComponent || ( t.isArrowFunctionExpression(node) || t.isFunctionExpression(node) || t.isClassMethod(node) || t.isObjectMethod(node) || t.isFunctionDeclaration(node)
10
44
10
+ 17 other calls in file
GitHub: jiangjing1994/fishhook
41 42 43 44 45 46 47 48 49 50
types.isStringLiteral(node) ) { return node.value } else if ( types.isFunctionExpression(node) || types.isArrowFunctionExpression(node) || types.isObjectMethod(node) ) { try { let code = generate.default(types.isObjectMethod(node) ? node.body : node).code
2
8
2
+ 5 other calls in file
GitHub: MaLuns/generate-vue-docs
34 35 36 37 38 39 40 41 42 43
// 获取Props默认值 function getDefaultVal(node) { if (types.isRegExpLiteral(node) || types.isBooleanLiteral(node) || types.isNumericLiteral(node) || types.isStringLiteral(node)) { return node.value } else if (types.isFunctionExpression(node) || types.isArrowFunctionExpression(node) || types.isObjectMethod(node)) { try { let code = generate.default(types.isObjectMethod(node) ? node.body : node).code let fun = eval(`0,${types.isObjectMethod(node) ? 'function ()' : ''} ${code}`) return JSON.stringify(fun())
6
7
0
GitHub: artemave/vjs
7 8 9 10 11 12 13 14 15 16
traverse(ast, { Statement(path) { const {loc} = path.node if (loc.start.line <= current_line && loc.end.line >= current_line) { if (t.isFunctionExpression(path.parent) || t.isArrowFunctionExpression(path.parent)) { return } if (result.line < loc.start.line) { result = loc.start
0
6
0
+ 10 other calls in file
102 103 104 105 106 107 108 109 110 111
) { return node.body.some(statement => hasBinding(statement, name)); } else if ( types.isFunctionDeclaration(node) || types.isFunctionExpression(node) || types.isArrowFunctionExpression(node) ) { return ( (node.id && node.id.name === name) || node.params.some(
0
2
2
+ 3 other calls in file
25 26 27 28 29 30 31 32 33 34
let lastImportSpecifier; traverse(ast, { ExportNamedDeclaration(path) { const init = get(path, 'node.declaration.declarations.0.init'); const isArrowFn = t.isArrowFunctionExpression(init); const isStringLiteral = t.isStringLiteral(init); if (isStringLiteral) { lastConstantExport = path;
0
2
0
+ 5 other calls in file
575 576 577 578 579 580 581 582 583 584
var list = null var res = $jsAst.find(selector[type]) if (res && res.length) { var node = res.match['list'][0].node if (t.isFunctionExpression(node) || t.isArrowFunctionExpression(node)) { if (type === propTypes.WATCH) { //TODO: 这里的判断可能有问题????? list = getDataOrPropsOrMethodsList($jsAst, type, fileKey, isCreate) } else {
221
0
0
GitHub: langyo/glimmer.js
112 113 114 115 116 117 118 119 120 121
t.traverseFast(ast, (node) => { if ( t.isObjectProperty(node) && node.key.value === 'scope' && t.isArrowFunctionExpression(node.value) ) { const scopeFnNode = node.value; const scopeArray = scopeFnNode.body.elements; scopeArray.forEach((scopeElementNode) => {
73
0
1
GitHub: HarryHoudini/reselector
66 67 68 69 70 71 72 73 74
let currentPath = p const prevPaths = [] do { isComponent = isComponent || ( t.isArrowFunctionExpression(currentPath.node) || t.isFunctionExpression(currentPath.node) || t.isClassExpression(currentPath.node) )
10
0
1
+ 5 other calls in file
GitHub: suchipi/tofu
104 105 106 107 108 109 110 111 112 113
2 - node.arguments.reduce((sum, node) => sum + node.end - node.start, 0) - // ", " between arguments (node.arguments.length - 1) * 2 && end < node.end) || t.isArrowFunctionExpression(node); const addToCollection: Action = ({ ast, cursor: [start, end] }) => { const [parents, path] = getFocusPath(ast, start); const collectionIndex = findLastIndex(
4
0
1
+ 5 other calls in file
GitHub: suchipi/tofu
165 166 167 168 169 170 171 172 173 174
return start; } } if ( t.isArrowFunctionExpression(node) && node.params.length == 0 && recursionDepth > 0 && start == node.start + 1 ) {
4
0
1
+ 13 other calls in file
158 159 160 161 162 163 164 165 166 167
const params = [...fn.params || []]; if (p0) { // 去掉类型 params[0] = t.identifier(p0.name); } const isArrow = t.isArrowFunctionExpression(fn); const fnExp = isArrow ? t.arrowFunctionExpression(params, fn.body, fn.async) : t.functionExpression(undefined, params, fn.body, fn.generator, fn.async); // fnExp.end = fn.end;
0
0
1
+ 25 other calls in file
520 521 522 523 524 525 526 527 528 529
} if (typeExp === "DECLARE" && types.isVariableDeclaration(path.node) && (types.isArrowFunctionExpression(path.node.declarations[0].init) || types.isFunctionExpression(path.node.declarations[0].init))) { // console.log("variable declarator", path.node); // if ( // types.isArrowFunctionExpression(path.node.declarations[0].init) || // types.isFunctionExpression(path.node.declarations[0].init) // ) { childToPut = types.callExpression(types.identifier(path.node.declarations[0].id.name), initAnnotationParser(immidateTopComment.value)); // } } // }
0
0
1
259 260 261 262 263 264 265 266 267 268
while (i >= 0) { if (expressionStatement && t.isExpressionStatement(parent, { expression: node }) || exportDefault && t.isExportDefaultDeclaration(parent, { declaration: node }) || arrowBody && t.isArrowFunctionExpression(parent, { body: node }) || forHead && t.isForStatement(parent, { init: node }) || forInHead && t.isForInStatement(parent, {
0
0
0
+ 2 other calls in file
18 19 20 21 22 23 24 25 26 27
* **/ const isAsyncFuncNode = node => t.isFunctionDeclaration(node, { async: true }) || t.isArrowFunctionExpression(node, { async: true }) || t.isFunctionExpression(node, { async: true
0
0
0
225 226 227 228 229 230 231 232 233 234
while (i >= 0) { if (t.isExpressionStatement(parent, { expression: node }) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node }) || considerArrow && t.isArrowFunctionExpression(parent, { body: node })) { return true; }
0
0
0
85 86 87 88 89 90 91 92 93
/** * Arrow function check */ if( astNode.init && t.isArrowFunctionExpression(astNode.init) && astNode.init.body && t.isBlockStatement(astNode.init.body) ) {
0
0
0
@babel/types.identifier is the most popular function in @babel/types (20936 examples)