How to use the isProgram function from babel-types

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

195
196
197
198
199
200
201
202
203
204
  path.scope.rename(path.node.id.name, file.property + '_local_fn_' + path.node.id.name);
  return;
}

// rename all top level variables to keep them local to the module
if (t.isVariableDeclaration(path.node) && t.isProgram(path.parent)) {
  path.node.declarations.forEach(function (declaration) {
    path.scope.rename(
      declaration.id.name,
      file.property + '_local_var_' + declaration.id.name
fork icon59
star icon89
watch icon10

+ 51 other calls in file

199
200
201
202
203
204
205
206
207
208
}

// rename all top level variables to keep them local to the module
if (
  t.isVariableDeclaration(path.node) &&
  t.isProgram(path.parent)
) {
  path.node.declarations.forEach(function (declaration) {
    path.scope.rename(
      declaration.id.name,
fork icon20
star icon50
watch icon8

84
85
86
87
88
89
90
91
92
93
94


function hasBinding(node, name) {
  if (Array.isArray(node)) {
    return node.some(ancestor => hasBinding(ancestor, name));
  } else if (
    babelTypes.isProgram(node) ||
    babelTypes.isBlockStatement(node) ||
    babelTypes.isBlock(node)
  ) {
    return node.body.some(statement => hasBinding(statement, name));
fork icon0
star icon49
watch icon0

+ 3 other calls in file

90
91
92
93
94
95
96
97
98
99

function hasBinding(node, name) {
  if (Array.isArray(node)) {
    return node.some(ancestor => hasBinding(ancestor, name));
  } else if (
    types.isProgram(node) ||
    types.isBlockStatement(node) ||
    types.isBlock(node)
  ) {
    return node.body.some(statement => hasBinding(statement, name));
fork icon0
star icon2
watch icon2

Other functions in babel-types

Sorted by popularity

function icon

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