How to use the objectMethod function from @babel/types

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

55
56
57
58
59
60
61
62
63
64

/**
 * 转换ClassMethod为ObjectMethod
 */
function transformClassMethodToObjectMethod(pathNode) {
        let node = t.objectMethod("method", pathNode.key, pathNode.params, pathNode.body, pathNode.computed);
        node.async = pathNode.async;
        return node;
}
/**
fork icon7
star icon38
watch icon2

+ 17 other calls in file

63
64
65
66
67
68
69
70
71
72
t.variableDeclarator(
  t.identifier(graphqlName),
  t.newExpression(typeMap.scalarTypeRef, [
    t.objectExpression([
      t.objectProperty(t.identifier('name'), t.stringLiteral(graphqlName)),
      t.objectMethod(
        'method',
        t.identifier('serialize'),
        [t.identifier('value')],
        t.blockStatement([t.returnStatement(t.identifier('value'))])
fork icon3
star icon46
watch icon11

130
131
132
133
134
135
136
137
138
139
        }
}
let pageWxsInfo = global.pageWxsInfo[key];
if (pageWxsInfo) {
        if (!node) {
                node = t.objectMethod("method", t.identifier(funName), [], t.blockStatement([]));
                liftCycleArr.unshift(node);
        }
        pageWxsInfo.forEach(obj => {
                let left = t.memberExpression(t.thisExpression(), t.identifier(obj.module));
fork icon222
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)