How to use the objectMethod function from babel-types
Find comprehensive JavaScript babel-types.objectMethod code examples handpicked from public code repositorys.
423 424 425 426 427 428 429 430 431 432
var func = null; // 区分类方法、对象方法、函数申明还是函数表达式 if (types.isClassMethod(node)) { func = types.classMethod(node.kind, node.key, params, types.BlockStatement([tryStatement]), node.computed, node.static); } else if (types.isObjectMethod(node)) { func = types.objectMethod(node.kind, node.key, params, types.BlockStatement([tryStatement]), node.computed); } else if (types.isFunctionDeclaration(node)) { func = types.functionDeclaration(node.id, params, types.BlockStatement([tryStatement]), isGenerator, isAsync); } else { func = types.functionExpression(node.id, params, types.BlockStatement([tryStatement]), isGenerator, isAsync);
6
14
2
+ 11 other calls in file
57 58 59 60 61 62 63 64 65 66
ExportDefaultDeclaration(path, state) { if(t.isObjectExpression(path.node.declaration)) { const props = path.node.declaration.properties const methodsNode = props.filter(p => t.isObjectProperty(p) && p.key.name === 'methods').shift() const argus = args.split(',').map(arg => t.Identifier(arg)) const m = t.objectMethod('method', t.Identifier(name), argus, t.BlockStatement([])) if (methodsNode) { methodsNode.value.properties.push(m) } else { props.push(t.objectProperty(t.Identifier('methods'), t.objectExpression([m])))
1
3
2
+ 11 other calls in file
34 35 36 37 38 39 40 41 42 43
), t.objectProperty( t.identifier('types'), t.arrayExpression([...types.map(type => t.identifier(type))]) ), t.objectMethod( 'method', t.identifier('resolveType'), [t.identifier('value')], t.blockStatement(typeChecks)
0
3
2
+ 5 other calls in file
GitHub: free-dev-gf/fe_build
114 115 116 117 118 119 120 121 122 123
types.BlockStatement([tryStatement]), node.computed, node.static ); } else if (types.isObjectMethod(node)) { func = types.objectMethod( node.kind, node.key, params, types.BlockStatement([tryStatement]),
0
0
0
babel-types.identifier is the most popular function in babel-types (4076 examples)