1 unstable release

0.1.0 Nov 22, 2021

#104 in #typescript-compiler

25 downloads per month
Used in swc_babel_compat

Apache-2.0/MIT

245KB
7.5K SLoC

Visitor pattern implementation for Babel AST.

Example

// Visit all Identifier nodes in the Babel AST and change the optional field to 
// Some(true) for each of them.

use swc_babel_visit::{VisitMut, VisitMutWith};
use swc_babel_ast::{Identifier, File};

struct Visitor;

impl VisitMut for Visitor {
    fn visit_mut_identifier(&mut self, node: &mut Identifier) {
        node.optional = Some(true);
    }
}

let ast: File = get_babel_ast();
let mut v = Visitor {};
ast.visit_mut_with(&mut v);

Dependencies

~4.5–10MB
~205K SLoC