浏览代码

Added examples to the `simplify` option in README.md

sanex3339 4 年之前
父节点
当前提交
c3fcbecbc9
共有 1 个文件被更改,包括 29 次插入1 次删除
  1. 29 1
      README.md

+ 29 - 1
README.md

@@ -780,7 +780,35 @@ Type: `boolean` Default: `true`
 
 Enables additional code obfuscation through simplification.
 
-##### :warning: in the future releases obfuscation of `boolean` literals (`true` => `!![]`) will be moved under this option. 
+##### :warning: in future releases obfuscation of `boolean` literals (`true` => `!![]`) will be moved under this option. 
+
+Example:
+```ts
+// input
+if (condition1) {
+    const foo = 1;
+    const bar = 2;
+  
+    console.log(foo);
+  
+    return bar;
+} else if (condition2) {
+    console.log(1);
+    console.log(2);
+    console.log(3);
+  
+    return 4;
+} else {
+    return 5;
+}
+
+// output
+if (condition1) {
+    const foo = 0x1, bar = 0x2;
+    return console['log'](foo), bar;
+} else
+    return condition2 ? (console['log'](0x1), console['log'](0x2), console['log'](0x3), 0x4) : 0x5;
+```
 
 ### `sourceMap`
 Type: `boolean` Default: `false`