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;
        }
    }
fork icon8
star icon11
watch icon7

+ 55 other calls in file

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'),
fork icon5
star icon43
watch icon10

+ 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
  );
}
fork icon62
star icon0
watch icon2

+ 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
fork icon17
star icon0
watch icon5

38
39
40
41
42
43
44
45
46
47
    ]),
  ),
);

const guard = t.ifStatement(
  t.logicalExpression(
    '&&',
    t.binaryExpression(
      '>',
      t.updateExpression('++', iterator, true),
fork icon4
star icon0
watch icon0

+ 3 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)