Skip to content

Commit

Permalink
feat(minifier): collapse var into for loop initializer
Browse files Browse the repository at this point in the history
`var a = 0; for(;a<0;a++) {}` => `for(var a = 0;a<0;a++) {}`
  • Loading branch information
Boshen committed Dec 26, 2024
1 parent c22062b commit 6055075
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 129 deletions.
5 changes: 5 additions & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ impl fmt::Display for VariableDeclarationKind {
}

impl ForStatementInit<'_> {
/// Is `var` declaration
pub fn is_var_declaration(&self) -> bool {
matches!(self, Self::VariableDeclaration(decl) if decl.kind.is_var())
}

/// LexicalDeclaration[In, Yield, Await] :
/// LetOrConst BindingList[?In, ?Yield, ?Await] ;
pub fn is_lexical_declaration(&self) -> bool {
Expand Down
Loading

0 comments on commit 6055075

Please sign in to comment.