27 releases (16 breaking)

Uses new Rust 2021

0.17.0 Jul 11, 2022
0.15.0 May 20, 2022
0.13.2 Mar 24, 2022
0.7.0 Dec 8, 2021
0.5.0 Oct 29, 2021
Download history 1621/week @ 2022-04-22 1475/week @ 2022-04-29 1907/week @ 2022-05-06 2290/week @ 2022-05-13 1677/week @ 2022-05-20 1673/week @ 2022-05-27 1390/week @ 2022-06-03 1385/week @ 2022-06-10 1521/week @ 2022-06-17 1894/week @ 2022-06-24 1655/week @ 2022-07-01 2104/week @ 2022-07-08 1606/week @ 2022-07-15 1838/week @ 2022-07-22 1748/week @ 2022-07-29 1866/week @ 2022-08-05

7,324 downloads per month
Used in 17 crates (14 directly)

MIT license

165KB
4.5K SLoC

deno_ast

Discord Chat

Source text parsing, lexing, and AST related functionality for Deno.

use deno_ast::parse_module;
use deno_ast::MediaType;
use deno_ast::ParseParams;
use deno_ast::SourceTextInfo;

let source_text = "class MyClass {}";
let text_info = SourceTextInfo::new(source_text.into());
let parsed_source = parse_module(ParseParams {
  specifier: "file:///my_file.ts".to_string(),
  media_type: MediaType::TypeScript,
  text_info,
  capture_tokens: true,
  maybe_syntax: None,
  scope_analysis: false,
}).expect("should parse");

// returns the comments
parsed_source.comments();
// returns the tokens if captured
parsed_source.tokens();
// returns the module (AST)
parsed_source.module();
// returns the `SourceTextInfo`
parsed_source.text_info();

Dependencies

~8–16MB
~333K SLoC