How to use the isProgram function from @babel/types
Find comprehensive JavaScript @babel/types.isProgram code examples handpicked from public code repositorys.
21 22 23 24 25 26 27 28 29 30
} } }, ExpressionStatement: { exit(path) { if (first && t.isProgram(path.parent)) { first = false; path.replaceWithMultiple(newSource); } }
17
65
8
434 435 436 437 438 439 440 441 442 443
sourceType: 'module', plugins: ['jsx'] // FIXME!!! presets: ['env] }); if (t.isFile(ast) && t.isProgram(ast.program) && ast.program.body.length === 1) { const exported = ast.program.body[0]; if (t.isExportNamedDeclaration(exported) && t.isVariableDeclaration(exported.declaration) && exported.declaration.declarations.length === 1) { const declaration = exported.declaration.declarations[0];
1
2
1
94 95 96 97 98 99 100 101 102 103
function hasBinding(node, name) { if (Array.isArray(node)) { return node.some(ancestor => hasBinding(ancestor, name)); } else if ( types.isProgram(node) || types.isBlockStatement(node) || types.isBlock(node) ) { return node.body.some(statement => hasBinding(statement, name));
0
2
2
+ 3 other calls in file
23 24 25 26 27 28 29 30 31
// Ignore block statements. if (t.isBlockStatement(cursor.scope.path)) { continue; } if (t.isFunction(cursor.scope.path) || t.isProgram(cursor.scope.path)) { break; } } while ((cursor = cursor.scope.path.parentPath));
0
1
1
+ 10 other calls in file
GitHub: arthuredelstein/hakk
227 228 229 230 231 232 233 234 235 236 237 238
const getEnclosingProperty = path => path.findParent((path) => path.isProperty()); const isTopLevelDeclaredObject = (path) => types.isVariableDeclarator(path.parentPath) && types.isVariableDeclaration(path.parentPath.parentPath) && types.isProgram(path.parentPath.parentPath.parentPath); const handleCallExpressionEnter = (path) => { if (path.node.callee.type !== 'MemberExpression' || path.node.callee.object.type !== 'Super') {
0
0
0
+ 21 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)