packages/flow-remove-types/index.js
// calling methods on the given visitor, providing context as the first argument.
calling methods on the given visitor, providing context as the first argument.
calling methods on the given visitor providing context as the first argument .
function visit(ast, context, visitor) {
  var stack;
  var parent;
  var keys = [];
  var index = -1;
  do {
    index++;
    if (stack && index === keys.length) {
      parent = stack.parent;
      keys = stack.keys;
      index = stack.index;
      stack = stack.prev;
    } else {
      var node = parent ? parent[keys[index]] : getProgram(ast);
      if (node && typeof node === 'object' && (node.type || node.length)) {
        if (node.type) {
          var visitFn = visitor[node.type];
          if (visitFn && visitFn(context, node, ast) === false) {
            continue;
          }
        }
        stack = {parent: parent, keys: keys, index: index, prev: stack};
        parent = node;
        keys = Object.keys(node);
        index = -1;
      }
    }
  } while (stack);
}
function visit ( ast , context , visitor ) { var stack ; var parent ; var keys = [ ] ; var index = - 1 ; do { index ++ ; if ( stack && index === keys . length ) { parent = stack . parent ; keys = stack . keys ; index = stack . index ; stack = stack . prev ; } else { var node = parent ? parent [ keys [ index ] ] : getProgram ( ast ) ; if ( node && typeof node === 'object' && ( node . type || node . length ) ) { if ( node . type ) { var visitFn = visitor [ node . type ] ; if ( visitFn && visitFn ( context , node , ast ) === false ) { continue ; } } stack = { parent : parent , keys : keys , index : index , prev : stack } ; parent = node ; keys = Object . keys ( node ) ; index = - 1 ; } } } while ( stack ) ; }
calling methods on the given visitor, providing context as the first argument.
calling methods on the given visitor providing context as the first argument .