How to use the isObjectMethod function from @babel/types

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

83
84
85
86
87
88
89
90
91
92

isComponent = isComponent || (
  t.isArrowFunctionExpression(node)
  || t.isFunctionExpression(node)
  || t.isClassMethod(node)
  || t.isObjectMethod(node)
  || t.isFunctionDeclaration(node)
)

if (!componentNode && isComponent) {
fork icon10
star icon44
watch icon10

+ 17 other calls in file

115
116
117
118
119
120
121
122
123

  throw `Cannot resolve arguments for ${node.type}`;
};

const getPropertyDescriptor = async ({ node, ast, cwd }) => {
  const valueNode = types.isObjectMethod(node) ? node : node.value;
  const descriptor = await createDescriptor({ node: valueNode, ast, cwd });
  const comments = getComments(node);
  const name = node.key.name;
fork icon2
star icon11
watch icon222

+ 3 other calls in file

42
43
44
45
46
47
48
49
50
51
) {
  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
    let fun = eval(`0,${types.isObjectMethod(node) ? 'function ()' : ''} ${code}`)
fork icon2
star icon8
watch icon2

125
126
127
128
129
130
131
132
133
134
135
  scope,
  id
}, localBinding = false) {
  if (node.id) return;


  if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, {
    kind: "method"
  })) && (!parent.computed || t.isLiteral(parent.key))) {
    id = parent.key;
  } else if (t.isVariableDeclarator(parent)) {
fork icon0
star icon1
watch icon1

+ 8 other calls in file

244
245
246
247
248
249
250
251
252
253

if (t.isAssignmentExpression(parent)) {
  node = parent.left;
} else if (t.isVariableDeclarator(parent)) {
  node = parent.id;
} else if (t.isObjectProperty(node) || t.isObjectMethod(node)) {
  node = node.key;
}

const parts = [];
fork icon0
star icon0
watch icon1

24
25
26
27
28
29
30
31
32
33
        async: true
    }) ||
    t.isFunctionExpression(node, {
        async: true
    }) ||
    t.isObjectMethod(node, {
        async: true
    });
module.exports = function (source) {
    let options = this.getOptions();
fork icon0
star icon0
watch icon0

54
55
56
57
58
59
60
61
62
63
  throw file.buildCodeFrameError(node, "Key conflict with sibling node");
}

let key, value;

if (t.isObjectProperty(node) || t.isObjectMethod(node) || t.isClassMethod(node)) {
  key = t.toComputedKey(node, node.key);
}

if (t.isProperty(node)) {
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)