How to use the isVariableDeclarator function from babel-types
Find comprehensive JavaScript babel-types.isVariableDeclarator code examples handpicked from public code repositorys.
GitHub: btd/documentation
195 196 197 198 199 200 201 202 203
// var Foo = { bar: ... } if (n.isIdentifier(path) && n.isObjectProperty(path.parentPath) && n.isObjectExpression(path.parentPath.parentPath) && n.isVariableDeclarator(path.parentPath.parentPath.parentPath)) { identifiers = [path.parentPath.parentPath.parentPath.node.id.name]; inferMembershipFromIdentifiers(comment, identifiers); }
510
0
2
+ 3 other calls in file
GitHub: mpvue/mpvue-loader
87 88 89 90 91 92 93 94 95 96
// return new Vue(App) // } // }) VariableDeclaration: function (path) { if (path.node.declarations && t.isVariableDeclarator(path.node.declarations[0]) && t.isNewExpression(path.node.declarations[0].init) && t.isIdentifier(path.node.declarations[0].init.callee, { name: 'Vue' }) ) { const fnExpression = t.functionExpression(
49
47
12
+ 43 other calls in file
GitHub: webflow/documentation
36 37 38 39 40 41 42 43 44 45
const comments = (path.node.leadingComments || []).filter(isJSDocComment); if (!comments.length) { // If this is the first declarator we check for comments on the VariableDeclaration. if ( t.isVariableDeclarator(path) && path.parentPath.get('declarations')[0] === path ) { return getComments(data, path.parentPath); }
509
3
3
101 102 103 104 105 106 107 108 109
return ast.program.body.find( stmt => types.isVariableDeclaration(stmt) && stmt.kind === kind && stmt.declarations.length === 1 && types.isVariableDeclarator(stmt.declarations[0]) && stmt.declarations[0].id.name === name ); }
0
2
1
+ 7 other calls in file
GitHub: Philmod/parcel
138 139 140 141 142 143 144 145 146 147
return parent.node.source.value === name; // e.g. var fs = require('fs'); } else if ( t.isVariableDeclarator(bindingNode) || t.isAssignmentExpression(bindingNode) ) { let left = bindingNode.id || bindingNode.left; let right = bindingNode.init || bindingNode.right;
0
1
2
babel-types.identifier is the most popular function in babel-types (4076 examples)