How to use the isFunction function from @babel/types

Find comprehensive JavaScript @babel/types.isFunction code examples handpicked from public code repositorys.

121
122
123
124
125
126
127
128
129
130
}
if (name in propertyHandlers) {
  propertyHandlers[name](prop.value);
} else if (
    (babel.isMethod(prop) && prop.kind === 'method') ||
    babel.isFunction(prop.value)) {
  const method = esutil.toScannedMethod(
      prop, this.document.sourceRangeForNode(prop), this.document);
  element.addMethod(method);
}
fork icon12
star icon0
watch icon0

148
149
150
151
152
153
154
155
156
157
},

ReturnStatement: {
    exit(path) {
        // for call stack management
        const parent = path.findParent(parent => t.isFunction(parent))
        if (!path.node.argument) {
            path.node.argument = t.identifier('undefined')
        }
        path.node.argument = proxy(path.node.argument, {
fork icon5
star icon27
watch icon1

+ 21 other calls in file

19
20
21
22
23
24
25
26
27
28
  comment.kind = 'class';
  if (node.abstract) {
    comment.abstract = true;
  }
} else if (
  t.isFunction(node) ||
  t.isTSDeclareMethod(node) ||
  t.isTSDeclareFunction(node) ||
  t.isFunctionTypeAnnotation(node) ||
  t.isTSMethodSignature(node)
fork icon509
star icon0
watch icon0

+ 20 other calls in file

97
98
99
100
101
102
103
104
105
106
  return comment;
}

function getReturnType(fn) {
  if (
    t.isFunction(fn) ||
    t.isTSDeclareFunction(fn) ||
    t.isTSDeclareMethod(fn) ||
    t.isFunctionTypeAnnotation(fn)
  ) {
fork icon509
star icon0
watch icon0

+ 3 other calls in file

211
212
213
214
215
216
217
218
219
220
      t.isNewExpression(argumentPath.node) ||
      t.isIdentifier(argumentPath.node))) ||
  t.isMemberExpression(argumentPath.node) ||
  t.isLiteral(argumentPath.node) ||
  t.isObjectExpression(argumentPath.node) ||
  t.isFunction(argumentPath.node) ||
  t.isClass(argumentPath.node)
) {
  return;
}
fork icon0
star icon3
watch icon3

+ 28 other calls in file

96
97
98
99
100
101
102
103
104
105
    return ONE_LINE;

if (isIf(path))
    return ONE_LINE;

if (path.parentPath.isCallExpression() && isFunction(path.parentPath.node.arguments[1]))
    return ONE_LINE;

if (isCoupleLines(path))
    return MANY_LINES;
fork icon0
star icon1
watch icon0

+ 5 other calls in file

65
66
67
68
69
70
71
72
73
74
    after: !node.consequent.length && parent.cases[parent.cases.length - 1] === node
  };
},

LogicalExpression(node) {
  if (t.isFunction(node.left) || t.isFunction(node.right)) {
    return {
      after: true
    };
  }
fork icon0
star icon0
watch icon0

Other functions in @babel/types

Sorted by popularity

function icon

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