How to use the isBooleanLiteral function from @babel/types
Find comprehensive JavaScript @babel/types.isBooleanLiteral code examples handpicked from public code repositorys.
301 302 303 304 305 306 307 308 309 310 311
traverse(ast, { WhileStatement: { exit(path) { let { node } = path; // 判断是否是目标节点 if (!(t.isUnaryExpression(node.test) || t.isBooleanLiteral(node.test))) return; // 判断类型: while(!![]) while(true) if (!(node.test.value || node.test.prefix)) return; // 判断值: while中的值是否为true if (!t.isBlockStatement(node.body)) return; // 判断是否是块语句 // 检查块语句中的内容是否满足要求
+ 2 other calls in file
GitHub: jiangjing1994/fishhook

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
+ 5 other calls in file
GitHub: MaLuns/generate-vue-docs
32 33 34 35 36 37 38 39 40 41
} } // 获取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
290 291 292 293 294 295 296 297 298 299 300 301
(declaration.id.name === 'utils' || argZeroEquals(declaration.init.arguments, './utils')) const node6Stuff = declaration => declaration.id.name === 'asyncawait' && btypes.isBooleanLiteral(declaration.init) const isNode6InterOpIt = path => btypes.isConditionalExpression(path.node.callee) && btypes.isIdentifier(path.node.callee.test, { name: 'asyncawait' })
GitHub: fish-uncle/uni-app

25 26 27 28 29 30 31 32 33 34
} const expr = parseExpression(str) if ( t.isStringLiteral(expr) || t.isNumericLiteral(expr) || t.isBooleanLiteral(expr) || t.isNullLiteral(expr) ) { return false }
+ 25 other calls in file
GitHub: hackerxian/rax

10 11 12 13 14 15 16 17 18 19
* @param {JSXElement|String|Number} el */ function parseElement(el) { if (t.isStringLiteral(el) || t.isNumericLiteral(el)) { return parseBaseStructure(el); } else if (t.isNullLiteral(el) || t.isBooleanLiteral(el) || t.isIdentifier(el, { name: 'undefined' } )) { return null; } else if (t.isArrayExpression(el)) { return parseElementArray(el); } else {
+ 3 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)