How to use the isClassMethod function from babel-types
Find comprehensive JavaScript babel-types.isClassMethod code examples handpicked from public code repositorys.
2 3 4 5 6 7 8 9 10 11
const ANONYMOUS_FUNCTION = 'anonymous function'; const isNodeTypeAFunction = n => t.isFunctionDeclaration(n) || t.isArrowFunctionExpression(n) || t.isClassMethod(n) || t.isFunctionExpression(n); // What to do with declareFunction type? const isPathTypeAFunction = p =>
2
60
3
118 119 120 121 122 123 124 125 126 127
return ast.program.body.find(types.isExportDefaultDeclaration); } function findClassMethodDeclaration(classDeclaration, method) { return classDeclaration.body.body.find( stmt => types.isClassMethod(stmt) && stmt.key.name === method ); } function findReturnStatement(body) {
0
2
1
+ 7 other calls in file
GitHub: mmoss/documentation
26 27 28 29 30 31 32 33 34 35
// If this is an ES6 class with a constructor method, infer // parameters from that constructor method. if (t.isClassDeclaration(path)) { let constructor = path.node.body.body.find(item => { // https://github.com/babel/babylon/blob/master/ast/spec.md#classbody return t.isClassMethod(item) && item.kind === 'constructor'; }); if (constructor) { return inferAndCombineParams(constructor.params, comment); }
509
0
2
4 5 6 7 8 9 10 11 12 13
function isModuleNode(node) { return types.isModuleDeclaration(node); } function isClassMethodBody(block) { return types.isClassMethod(block.container); } function isModule(block) { return block.node.body.some(isModuleNode);
0
0
1
+ 3 other calls in file
babel-types.identifier is the most popular function in babel-types (4076 examples)