How to use the isArrayExpression function from @babel/types
Find comprehensive JavaScript @babel/types.isArrayExpression code examples handpicked from public code repositorys.
190 191 192 193 194 195 196 197 198 199
//如果父级不为data时,那么就加入生命周期,比如app.js下面的全局变量 if (value && value == dataValue) { vistors.data.handle(path.node); //如果data下面的变量为数组时,不遍历下面的内容,否则将会一一列出来 if (path.node.value && t.isArrayExpression(path.node.value)) path.skip(); } else { const node = path.node.value; if (t.isFunctionExpression(node) || t.isArrowFunctionExpression(node) || t.isObjectExpression(node)) { //这里function
223
0
0
+ 15 other calls in file
GitHub: Ntrashh/BossASTDecode
155 156 157 158 159 160 161 162 163 164
if (!types.isBreakStatement(conseq[conse])) { // 进入这个分支也会有三种情况 //分三种情况1、列表的定义 2、原列表的添加 3、返回类型 //先判断是否是列表的定义 if (types.isVariableDeclaration(conseq[conse]) && conseq[conse].declarations.length == 1 && types.isArrayExpression(conseq[conse].declarations[0].init)) { //如果确实是列表的定义,就把列表的值提取出来放入到字典中 let value = getArr(conseq[conse].declarations[0].init.elements); let name = conseq[conse].declarations[0].id.name; if (arrDict[name] == undefined) {
6
18
1
+ 5 other calls in file
GitHub: Leman-li/tanfu.js
64 65 66 67 68 69 70 71 72 73
var _path$node, _path$node$expression; if (t.isIdentifier((_path$node = path.node) === null || _path$node === void 0 ? void 0 : (_path$node$expression = _path$node.expression) === null || _path$node$expression === void 0 ? void 0 : _path$node$expression.callee) && path.node.expression.callee.name === 'Component') { traverse(path.node, { ObjectProperty: function ObjectProperty(_path) { if (t.isIdentifier(_path.node.key) && _path.node.key.name === 'providers' && t.isArrayExpression(_path.node.value)) { var newValue = t.arrayExpression(); _path.node.value.elements.forEach(function (v) { if (t.isIdentifier(v)) {
5
8
2
+ 8 other calls in file
GitHub: MaLuns/generate-vue-docs
51 52 53 54 55 56 57 58 59 60
let { key: { name }, leadingComments, value } = prop props[name] = { name } leadingComments && (props[name].desc = leadingComments[0].value.trim()); // 如果是标识或数组 说明只声明了类型 if (types.isIdentifier(value) || types.isArrayExpression(value)) { props[name].type = getPropType(value) } else if (types.isObjectExpression(value)) { value.properties.map(item => { let node = item
6
7
1
+ 5 other calls in file
GitHub: suchipi/tofu
118 119 120 121 122 123 124 125 126 127
if ( (t.isArrayExpression(node) || t.isArrayExpression(parent)) && recursionDepth > 0 ) { const arrayNode = t.isArrayExpression(node) ? node : parent; const emptyElementIndexes = []; const elementEnds = []; for (let i = 0; i < arrayNode.elements.length; i++) { const element = arrayNode.elements[i];
4
0
1
+ 27 other calls in file
82 83 84 85 86 87 88 89 90 91
n.parentPath.replaceWith(newNode) } } }) } } else if ( t.isArrayExpression(path.node.init) ){ // No handling for arrays right now } else if ( t.isBinaryExpression(path.node.init) ){ // No handling for ^^ right now } else if ( t.isFunctionExpression(path.node.init) ){
1
6
7
GitHub: wwhtrbbtt/GPJSD
138 139 140 141 142 143 144 145 146 147
// replace with 'true' p.replaceWith(t.booleanLiteral(true)); } } if ( t.isArrayExpression(p.node.argument) && JSON.stringify(p.node.argument.elements) == '[]' ) { // get every '![]' // replace with 'false'
1
5
1
+ 356 other calls in file
683 684 685 686 687 688 689 690 691 692
var typeNode = properties.find(obj => obj.key && (obj.key.name || obj.key.value) === "type") if (typeNode) typeList.push(typeNode.value.name) //optionalTypes: 属性的类型(可以指定多个) var optionalTypes = properties.find(obj => obj.key && (obj.key.name || obj.key.value) === "optionalTypes") if (optionalTypes && t.isArrayExpression(optionalTypes.value)) { var optionalTypeList = optionalTypes.value.elements.map(obj => (obj.name || obj.value)) typeList.push(...optionalTypeList) } } else {
221
0
0
127 128 129 130 131 132 133 134 135 136
checkPropDefaultValueType(propItemName, typeNode.value.name, valueNode.value, fileKey) } if (typeNode && (typeNode.value.name === "Array" || typeNode.value.name === "Object")) { if (valueNode && (t.isObjectExpression(valueNode.value) || t.isArrayExpression(valueNode.value))) { /** * shopConfig: { * type: Object, * value: {},
221
0
0
+ 3 other calls in file
74 75 76 77 78 79 80 81 82 83
if (baseExportName !== 'default' && !parentPath.parentPath.isProgram()) { parentPath = parentPath.parentPath; } var css = (0, _utils.cssToBabelType)(styles.css); var newPath = t.isArrayExpression(css) ? css : t.newExpression(t.identifier('String'), [css]); // default exports if (baseExportName === 'default') { var defaultExportIdentifier = path.scope.generateUidIdentifier('defaultExport'); parentPath.insertBefore(t.variableDeclaration('const', [t.variableDeclarator(defaultExportIdentifier, newPath)]));
0
0
1
@babel/types.identifier is the most popular function in @babel/types (20936 examples)