How to use the arrayExpression function from babel-types
Find comprehensive JavaScript babel-types.arrayExpression code examples handpicked from public code repositorys.
GitHub: drd/jsxlate
25 26 27 28 29 30 31 32 33 34
const vars = freeVariablesInMessage(node); const message = extractElementMessageWithoutSideEffects(node); const fallback = this.makeFallback(node); const transformed = transformElementMarker({ MESSAGE: types.stringLiteral(message), ARGS: types.arrayExpression( vars.map(v => types.identifier(v)) ), FALLBACK: fallback, });
6
21
3
+ 3 other calls in file
GitHub: sbekrin/cljs-babel
73 74 75 76 77 78 79 80 81 82
// :foo -> 'foo' case l.KeywordNode: return t.stringLiteral(resolveKeyword(node.name)); // [1 2 3] -> [1, 2, 3] case l.VectorNode: return t.arrayExpression(node.values.map(translate)); // {:foo 1, :bar 2} -> new Map([['foo', 1], ['bar', 2]]) case l.MapNode: { invariant( isEven(node.values.length),
1
10
2
+ 29 other calls in file
39 40 41 42 43 44 45 46 47 48
const NullableTypeAnnotation = (node, initialPath) => t.objectExpression([ t.objectProperty( t.identifier('anyOf'), t.arrayExpression([ NullLiteralTypeAnnotation(), convert(node.typeAnnotation, initialPath) ]) )
1
9
2
+ 92 other calls in file
12 13 14 15 16 17 18 19 20 21
} else if (typeof obj === 'string') { return t.stringLiteral(obj); } else if (typeof obj === 'boolean') { return t.booleanLiteral(obj); } else if (Array.isArray(obj)) { return t.arrayExpression(obj.map(objToAst)); } else if (typeof obj === 'object') { const properties = Object.getOwnPropertyNames(obj).map(prop => { return t.objectProperty(t.stringLiteral(prop), objToAst(obj[prop])); });
1
5
2
+ 3 other calls in file
GitHub: yutiansut/mpx
131 132 133 134 135 136 137 138 139
} last = current current = current.parentPath } rightExpression = t.arrayExpression([rightExpression, t.stringLiteral(firstKey)]) // 构造赋值语句并挂到要改的path下,等对memberExpression访问exit时处理 last.assignment = t.assignmentExpression('=', t.memberExpression(t.identifier('renderData'), t.stringLiteral(keyPath.toString()), true), rightExpression) }
349
0
3
118 119 120 121 122 123 124 125 126 127
return t.callExpression(c.HELPER, [ c.CONTEXT, c.HELPERS, t.stringLiteral(branch.helperName), t.arrayExpression(compile(branch.args)), ]); }, OpenIf(branch, nextBranch) { let test = transforms[branch.test.tokenType](branch.test);
17
0
5
58 59 60 61 62 63 64 65 66 67
return arrayTypeAssertTemplate(valueAssertion); }; const unionNodeTypeAssertTemplate = names => tea.callExpression(tea.identifier('assertOneOf'), [ tea.arrayExpression(names.map(name => tea.stringLiteral(name))) ]); const valueOfUnionNodeType = valueNode => { if (
5
0
2
+ 23 other calls in file
15 16 17 18 19 20 21 22 23 24
[ R.is(Object), buildObjectLiteral ], [ R.T, nullary(types.nullLiteral) ] ]); function buildArrayLiteral(arr) { return types.arrayExpression(R.map(buildLiteral, arr)); } // Please note that we only support simple non-circular javascript constructs function buildObjectLiteral(obj) {
4
0
6
+ 9 other calls in file
32 33 34 35 36 37 38 39 40 41
false, false ), t.objectProperty( t.identifier('types'), t.arrayExpression([...types.map(type => t.identifier(type))]) ), t.objectMethod( 'method', t.identifier('resolveType'),
0
3
2
+ 5 other calls in file
GitHub: sorrycc/taro
199 200 201 202 203 204 205 206 207 208
} }) if (defaultSpecifier) { let objArr = [t.nullLiteral()] if (Array.isArray(obj)) { objArr = t.arrayExpression(astConvert.array(obj)) } else { objArr = t.objectExpression(astConvert.obj(obj)) } astPath.replaceWith(t.variableDeclaration('const', [t.variableDeclarator(t.identifier(defaultSpecifier), objArr)]))
0
4
5
+ 3 other calls in file
GitHub: krasimir/cssx
131 132 133 134 135 136 137 138 139 140
if (result[rulesBuffer[name].index].expression.right.type === 'ArrayExpression') { result[rulesBuffer[name].index].expression.right.elements.push( t.identifier(current.expression.right.name) ); } else { result[rulesBuffer[name].index].expression.right = t.arrayExpression([ t.identifier(rulesBuffer[name].rule.expression.right.name), t.identifier(current.expression.right.name) ]); }
47
0
36
14 15 16 17 18 19 20 21 22 23
classNameValue = classNameAttr.value.expression; } else if (classNameAttr && t.isStringLiteral(classNameAttr.value)) { classNameValue = classNameAttr.value; } let classNameArr = classNameValue ? t.arrayExpression([ classNameValue ]) : t.arrayExpression([]); let classObjEntries = t.callExpression(
0
4
0
GitHub: eyasudev/vue-to-react
97 98 99 100 101 102 103 104 105 106
val = type === 'number' ? t.numericLiteral(Number(v)) : type === 'string' ? t.stringLiteral(v) : t.booleanLiteral(v); } else { continue; } } else if (obj.type === 'array') { val = t.arrayExpression(obj.value.elements); } else if (obj.type === 'object') { val = t.objectExpression(obj.value.properties); } else { switch (obj.type) {
0
0
0
GitHub: ygmpkk/taro
90 91 92 93 94 95 96 97 98 99
]) } const buildRouterStarter = ({ pages, packageName }) => { const importers = pages.map(buildRouterImporter) const initArrNode = t.arrayExpression(importers) return t.expressionStatement( t.callExpression( t.memberExpression(
0
0
1
+ 3 other calls in file
19 20 21 22 23 24 25 26 27 28
const generateLiteral = value => { if (_.isString(value)) return t.stringLiteral(value); if (_.isBoolean(value)) return t.booleanLiteral(value); if (_.isNumber(value)) return t.numericLiteral(value); if (_.isNull(value)) return t.nullLiteral(); if (_.isArray(value)) return t.arrayExpression(value.map(generateLiteral)); if (_.isObject(value)) { const properties = Object.keys(value).map(key => t.objectProperty(t.identifier(key), generateLiteral(value[key])) );
0
0
4
+ 15 other calls in file
78 79 80 81 82 83 84 85 86 87
...Object.entries( description.belongsToMany, ).map(([attribute, options]) => { return t.objectProperty( t.stringLiteral(attribute), t.arrayExpression([modelVar(options.target_name)]), ); }), ]), ],
0
0
2
babel-types.identifier is the most popular function in babel-types (4076 examples)