How to use the logicalExpression function from babel-types
Find comprehensive JavaScript babel-types.logicalExpression code examples handpicked from public code repositorys.
21 22 23 24 25 26 27 28 29 30
function createNullElement(error, statement, expressions) { let condition = null; for (const expression of expressions) { const cond =t.logicalExpression("||", t.binaryExpression('==', t.unaryExpression('typeof',expression), t.stringLiteral('undefined')),t.binaryExpression("==", expression, t.nullLiteral())); if (condition != null) { condition = t.logicalExpression("&&", condition, cond) } else { condition = cond; } }
8
11
7
+ 55 other calls in file
GitHub: pugjs/then-pug
79 80 81 82 83 84 85 86 87 88
} Compiler.prototype.ast_variableDeclaration = function() { return t.variableDeclaration('var', [ t.variableDeclarator(t.identifier('pug_mixins'), t.logicalExpression('||', t.memberExpression(t.identifier('locals'),t.identifier('pug_mixins')) , t.objectExpression([]))), t.variableDeclarator(t.identifier('pug_interp'), null), t.variableDeclarator(t.identifier('_ref'),
5
43
10
+ 15 other calls in file
56 57 58 59 60 61 62 63 64
// if spread operators occur after propValue, create a binary expression for each operator // i.e. before1.propValue || before2.propValue || propValue // TODO: figure out how to do this without all the extra parens if (applicableSpreads.length > 0) { propValue = applicableSpreads.reduce( (acc, val) => t.logicalExpression('||', accessSafe(val, propName), acc), propValue ); }
62
0
2
+ 5 other calls in file
30 31 32 33 34 35 36 37 38 39
// context && context['prop'] && context['prop'][5] ... let last = c.CONTEXT; return t.callExpression(c.GUARD, [ paths.reduce((out, p) => { last = t.memberExpression(last, p, true); return t.logicalExpression('&&', out, last); }, last), ]); } // take an array of string expressions
17
0
5
GitHub: replit4/replbox
38 39 40 41 42 43 44 45 46 47
]), ), ); const guard = t.ifStatement( t.logicalExpression( '&&', t.binaryExpression( '>', t.updateExpression('++', iterator, true),
4
0
0
+ 3 other calls in file
babel-types.identifier is the most popular function in babel-types (4076 examples)