How to use the isCallExpression function from babel-types

Find comprehensive JavaScript babel-types.isCallExpression code examples handpicked from public code repositorys.

26
27
28
29
30
31
32
33
34
35
if (t.isConditionalExpression(expr) || t.isIfStatement(expr)) {
    return condition(expr.test, expr.consequent, expr.alternate, modules);
} else if (t.isLogicalExpression(expr) && expr.operator === '&&') {
    return condition(expr.left, expr.right, null, modules);
} else if (
    t.isCallExpression(expr) &&
    expr.callee.property.name === 'map'
) {
    // 处理列表指令
    if (expr.arguments[0].type === 'ArrowFunctionExpression') {
fork icon330
star icon0
watch icon1

+ 13 other calls in file

92
93
94
95
96
97
98
99
100
101
const parentNode = thisPath.parentPath.parentPath.parent;
const isValid = t.isExpressionStatement(parentNode) || 
    t.isVariableDeclaration(parentNode) ||
    t.isBlockStatement(parentNode) || 
    t.isJSXElement(parentNode) || 
    t.isCallExpression(parentNode) || 
    (t.isJSXAttribute(parentNode) && !parentNode.name.name.startsWith('on'));

if (isValid) {
    // prop
fork icon64
star icon411
watch icon8

40
41
42
43
44
45
46
47
48
49
    t.isIdentifier(node.property, { name: 'exports' })
  );
}
function isRequire(node, filename) {
  if (
    t.isCallExpression(node) &&
    t.isIdentifier(node.callee, { name: 'require' }) &&
    node.arguments.length === 1 &&
    t.isStringLiteral(node.arguments[0])
  ) {
fork icon59
star icon89
watch icon10

+ 25 other calls in file

109
110
111
112
113
114
115
116
117
118
}

Compiler.prototype.ast_postprocess = function(ast) {
    let needCompaction = function(c) {
      return t.isExpressionStatement(c)
                && t.isCallExpression(c.expression)
                && t.isMemberExpression(c.expression.callee)
                && t.isIdentifier(c.expression.callee.object)
                && c.expression.callee.object.name === 'buf'
                && t.isIdentifier(c.expression.callee.property)
fork icon5
star icon43
watch icon10

+ 7 other calls in file

198
199
200
201
202
203
204
205
206
207

const url = types.identifier('url')
const routeName = nameInfo.value.value

let expressions, quasis
if (paramsItems.some(item => types.isCallExpression(item.value) || types.isMemberExpression(item.value))) {
  const expressionList = paramsItems.filter(item => types.isCallExpression(item.value) || types.isMemberExpression(item.value))
  const literalList = paramsItems.filter(item => types.isLiteral(item.value))
  const templateElementLastItem = literalList.reduce((finalString, cur) => {
    return `${finalString}&${cur.key.name}=${cur.value.value}`
fork icon4
star icon12
watch icon2

+ 39 other calls in file

32
33
34
35
36
37
38
39
40
41

// delete super(props) and prepend later
traverse(p.node, {
    enter: function enter(p) {

        if (t.isExpressionStatement(p.node) && t.isCallExpression(p.node.expression) && t.isSuper(p.node.expression.callee)) {

            p.remove();
        }
    }
fork icon1
star icon11
watch icon1

+ 5 other calls in file

32
33
34
35
36
37
38
39
40
41
// delete super(props) and prepend later
traverse(p.node, {
    enter (p) {
        
        if (t.isExpressionStatement(p.node) && 
            t.isCallExpression(p.node.expression) &&
            t.isSuper(p.node.expression.callee)) {
            
                p.remove();
                
fork icon1
star icon11
watch icon1

+ 3 other calls in file

90
91
92
93
94
95
96
97
98
99
  if (identifierName === 'module' && !path.scope.hasBinding('module')) {
    const parentPath = path.parentPath;
    const parentNode = path.parentPath.node;
    if (t.isMemberExpression(parentNode) && parentNode.object === path.node) {
      const name = parentNode.computed ? parentNode.property.value : parentNode.property.name;
      if (name === 'require' && t.isCallExpression(parentPath.parent) && parentPath.parent.callee === parentPath.node)
        addDependency(parentPath.parent.arguments[0], state);
    }
  }
}
fork icon2
star icon3
watch icon3

719
720
721
722
723
724
725
726
727
728
Program: {
    exit(astPath) {
        const node = astPath.node;
        node.body.forEach((bodyNode) => {
            if (t.isExpressionStatement(bodyNode)
                && t.isCallExpression(bodyNode.expression)
                && t.isIdentifier(bodyNode.expression.callee)
                && bodyNode.expression.callee.name === 'mountApis') {
                const mountApisOptNode = bodyNode.expression.arguments[0];
                if (t.isObjectExpression(mountApisOptNode)) {
fork icon0
star icon0
watch icon0

+ 11 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)