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
fork icon223
star icon0
watch icon0

+ 15 other calls in file

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) {
fork icon6
star icon18
watch icon1

+ 5 other calls in file

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)) {
fork icon5
star icon8
watch icon2

+ 8 other calls in file

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
fork icon6
star icon7
watch icon1

+ 5 other calls in file

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];
fork icon4
star icon0
watch icon1

+ 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) ){
fork icon1
star icon6
watch icon7

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'
fork icon1
star icon5
watch icon1

+ 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 {
fork icon221
star icon0
watch icon0

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: {},
fork icon221
star icon0
watch icon0

+ 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)]));
fork icon0
star icon0
watch icon1

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)