use simpler example

This commit is contained in:
Dan Wolff 2018-02-05 23:00:11 +01:00
parent 5a935f156b
commit 07f72ea7fb

View File

@ -25,30 +25,31 @@ Tests that cannot be expressed as a simple AST can be found in `test/mocha`.
- If both sides of a comparison are of the same type, `==` and `!=` are used. - If both sides of a comparison are of the same type, `==` and `!=` are used.
- Multiline conditions place `&&` and `||` first on the line. - Multiline conditions place `&&` and `||` first on the line.
Example: **Example feature**
```js ```js
if (compressor.option("comparisons")) switch (self.operator) { OPT(AST_Debugger, function(self, compressor) {
case "==": if (compressor.option("drop_debugger"))
case "!=": return make_node(AST_EmptyStatement, self);
// void 0 == x => null == x return self;
if (!is_strict_comparison && is_undefined(self.left, compressor)) { });
self.left = make_node(AST_Null, self.left); ```
**Example test**
```js
drop_debugger: {
options = {
drop_debugger: true,
} }
// "undefined" == typeof x => undefined === x input: {
else if (compressor.option("typeofs") debugger;
&& self.left instanceof AST_String if (foo) debugger;
&& self.left.value == "undefined" }
&& self.right instanceof AST_UnaryPrefix expect: {
&& self.right.operator == "typeof") { if (foo);
var expr = self.right.expression;
if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
: !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
self.right = expr;
self.left = make_node(AST_Undefined, self.left).optimize(compressor);
if (self.operator.length == 2) self.operator += "=";
}
} }
...
} }
``` ```