How to use the traverseFast function from @babel/types

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

32
33
34
35
36
37
38
39
40
41
  };
}

function validateOutputAst(ast) {
  const seenNodes = new Set();
  t.traverseFast(ast, function enter(node) {
    if (seenNodes.has(node)) {
      throw new Error(
        'Found a duplicate ' +
          node.type +
fork icon623
star icon1
watch icon0

92
93
94
95
96
97
98
99
100
101
const compiled = precompile(templateString, precompileOptions);
const ast = parse(`(${compiled})`);

let metaSeen = false;

t.traverseFast(ast, (node) => {
  if (t.isObjectProperty(node)) {
    if (node.key.value === 'meta') {
      metaSeen = true;
      node.value.properties.push(t.objectProperty(t.identifier('scope'), scopeNode));
fork icon73
star icon0
watch icon1

68
69
70
71
72
73
74
75
76
77
78
79
traverse.visitors = visitors;
traverse.verify = visitors.verify;
traverse.explode = visitors.explode;


traverse.cheap = function (node, enter) {
  return t.traverseFast(node, enter);
};


traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
  const keys = t.VISITOR_KEYS[node.type];
fork icon0
star icon0
watch icon0

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)