1 possible answer(s) on “How to traverse root path

  1. This works for me.

    function traverseFromRoot(path, visitor, state) {
        visitor = traverse.visitors.explode(visitor);
        if (visitor[path.type] && visitor[path.type].enter) visitor[path.type].enter[0].call(state, path, state);
        path.traverse(visitor, state);
        if (visitor[path.type] && visitor[path.type].exit) visitor[path.type].exit[0].call(state, path, state);
    }