How to use the isFor function from @babel/types

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

167
168
169
170
171
172
173
174
175
176
const declarations = []
const isFor = t.isForInStatement(path.parent) || t.isForOfStatement(path.parent)
path.get("declarations").forEach(traverseDeclarations(path, isFor, declarations))

if (isFor) {
    const parent = path.findParent(parent => t.isFor(parent))

    parent.node.body.body = [
        ...declarations.map(([node, details]) => proxy(node, details)),
        ...parent.node.body.body
fork icon5
star icon27
watch icon1

+ 21 other calls in file

138
139
140
141
142
143
144
145
146
147
148
149
function TSInferType(node, parent) {
  return t.isTSArrayType(parent) || t.isTSOptionalType(parent);
}


function BinaryExpression(node, parent) {
  return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
}


function SequenceExpression(node, parent) {
  if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) {
fork icon0
star icon0
watch icon0

+ 2 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 (20936 examples)