Function deno_ast::parse_program_with_post_process

source ·
pub fn parse_program_with_post_process(
    params: ParseParams,
    post_process: impl FnOnce(Program, &Globals) -> Program,
) -> Result<ParsedSource, ParseDiagnostic>
Expand description

Parses the provided information as a program with the option of providing some post-processing to the result.

§Example

deno_ast::parse_program_with_post_process(
 deno_ast::ParseParams {
   specifier: deno_ast::ModuleSpecifier::parse("file:///my_file.ts").unwrap(),
   media_type: deno_ast::MediaType::TypeScript,
   text: "console.log(4);".into(),
   capture_tokens: true,
   maybe_syntax: None,
   scope_analysis: false,
 },
 |program, _globals| {
   // do something with the program here before it gets stored
   program
 },
);