How to use the unaryExpression function from babel-types

Find comprehensive JavaScript babel-types.unaryExpression code examples handpicked from public code repositorys.

187
188
189
190
191
192
193
194
195
196
[t.identifier('key')],
t.blockStatement([
  t.ifStatement(
    t.binaryExpression(
      '!=',
      t.unaryExpression(
        'typeof',
        t.memberExpression(
          t.identifier('snapshot'),
          t.memberExpression(
fork icon2
star icon5
watch icon3

+ 9 other calls in file

119
120
121
122
123
124
125
126
127
128
  return t.identifier('NaN');
// Infinity -> Infinity
// -Infinity -> -Infinity
case l.InfinityNode:
  return node.negative
    ? t.unaryExpression('-', t.identifier('Infinity'))
    : t.identifier('Infinity');
// nil -> null
case l.NullNode:
  return t.nullLiteral();
fork icon1
star icon10
watch icon2

+ 9 other calls in file

124
125
126
127
128
129
130
131
132
133
  ]);
},
OpenIf(branch, nextBranch) {
  let test = transforms[branch.test.tokenType](branch.test);
  if (branch.not) {
    test = t.unaryExpression('!', test, true);
  }

  let alternate = t.stringLiteral('');
  if (nextBranch && nextBranch.tokenType === 'Else') {
fork icon17
star icon0
watch icon5

13
14
15
16
17
18
19
20
21
22
) {
  var snapshotCall = path.findParent((path) => path.isCallExpression());

  snapshotCall.insertAfter(
    t.ifStatement(
      t.unaryExpression('!', t.identifier('fromTheFuture'), true),
      t.blockStatement(
        [
          t.expressionStatement(
            t.callExpression(t.memberExpression(t.identifier('console'), t.identifier('log')), [
fork icon2
star icon5
watch icon3

Other functions in babel-types

Sorted by popularity

function icon

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