All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.shapesecurity.shift.minifier.README.md Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
Shift AST Minifier
==================

## Description

The `Minifier` class takes a `Script` object and transforms the AST so that it may be represented using the smallest
source length.

## Usage

```java
import com.shapesecurity.shift.minifier.Minifier;
import com.shapesecurity.shift.parser.Parser;
import com.shapesecurity.shift.codegen.CodeGen;

// parse a javascript program
String js = "a; b;";
Script p = Parser.parse(js);

// specifying reduction/expansion rules for minification
List reductionRules = List.list<>(FlattenBlocks.INSTANCE, ReduceNestedIfStatements.INSTANCE, ...);
List expansionRules = List.list<>();
Script pPrime = Minifier.minify(p, reductionRules, expansionRules);
String minified1 = CodeGen.codeGen(pPrime);

// using the default sets of reduction/expansion rules
Script pPrimePrime = Minifier.minify(p);
String minified2 = CodeGen.codeGen(pPrimePrime);
```




© 2015 - 2024 Weber Informatics LLC | Privacy Policy