소스 검색

Changed `stringArrayIntermediateVariablesCount` option description

sanex 4 년 전
부모
커밋
e87565bd9e
6개의 변경된 파일40개의 추가작업 그리고 27개의 파일을 삭제
  1. 1 1
      CHANGELOG.md
  2. 31 17
      README.md
  3. 0 0
      dist/index.cli.js
  4. 0 0
      dist/index.js
  5. 1 1
      src/cli/JavaScriptObfuscatorCLI.ts
  6. 7 8
      test/dev/dev.ts

+ 1 - 1
CHANGELOG.md

@@ -2,7 +2,7 @@ Change Log
 
 v2.2.0
 ---
-* **New option:** `stringArrayIntermediateVariablesCount` sets the passed amount of intermediate variables for the `string array`
+* **New option:** `stringArrayIntermediateVariablesCount` sets the maximum count of intermediate variables for the `string array` inside each lexical scope
 
 v2.1.0
 ---

+ 31 - 17
README.md

@@ -955,37 +955,51 @@ Type: `number` Default: `0`
 
 ##### :warning: [`stringArray`](#stringarray) option must be enabled
 
-Sets the passed amount of intermediate variables for the `string array`. 
+Sets the maximum count of intermediate variables for the `string array` inside each lexical scope.
+The actual count of intermediate variables inside each scope cannot be higher than a number of `literal` nodes within this scope.
 
 Example:
 ```ts
 // Input
 const foo = 'foo';
 const bar = 'bar';
-const baz = 'baz';
+        
+function test () {
+    const baz = 'baz';
+    const bark = 'bark';
+    const hawk = 'hawk';
+}
 
-console.log(foo, bar, baz);
+const eagle = 'eagle';
 
 // Output, stringArrayIntermediateVariablesCount: 5
-const _0x513c = [
+const _0x3018 = [
     'foo',
     'bar',
     'baz',
-    'log'
+    'bark',
+    'hawk',
+    'eagle'
 ];
-const _0x19a1 = function (_0x513ce6, _0x135380) {
-    _0x513ce6 = _0x513ce6 - 0x0;
-    let _0x19a103 = _0x513c[_0x513ce6];
-    return _0x19a103;
+const _0x380f = function (_0x30182a, _0x380f29) {
+    _0x30182a = _0x30182a - 0x0;
+    let _0x4e002c = _0x3018[_0x30182a];
+    return _0x4e002c;
 };
-const _0x3745 = _0x19a1;
-const _0x261a = _0x19a1;
-const _0x2f15 = _0x19a1;
-const _0x4a63 = _0x19a1;
-const _0x2e9d = _0x19a1;
-const foo = _0x4a63('0x0');
-const bar = _0x3745('0x1');
-const baz = _0x2e9d('0x2');
+const _0xe4db7c = _0x380f;
+const _0x26ca42 = _0x380f;
+const _0x58c610 = _0x380f;
+const foo = _0x58c610('0x0');
+const bar = _0x26ca42('0x1');
+function test() {
+    const _0x500eda = _0x380f;
+    const _0x1d1760 = _0x380f;
+    const _0x4ca8b0 = _0x380f;
+    const _0x4e002c = _0x4ca8b0('0x2');
+    const _0x573b1c = _0x1d1760('0x3');
+    const _0x1fb6ef = _0x500eda('0x4');
+}
+const eagle = _0x26ca42('0x5');
 ```
     
 ### `stringArrayThreshold`

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/index.cli.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/index.js


+ 1 - 1
src/cli/JavaScriptObfuscatorCLI.ts

@@ -341,7 +341,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
             )
             .option(
                 '--string-array-intermediate-variables-count <number>',
-                'Sets the passed amount of intermediate variables for the string array.',
+                'Sets the maximum count of intermediate variables for the string array inside each lexical scope',
                 parseInt
             )
             .option(

+ 7 - 8
test/dev/dev.ts

@@ -8,24 +8,23 @@ import { StringArrayEncoding } from '../../src/enums/StringArrayEncoding';
 
     let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
         `
+            const foo = 'foo';
+            const bar = 'bar';
+                    
             function test () {
-                const foo = 'foo';
-                const bar = 'bar';
                 const baz = 'baz';
+                const bark = 'bark';
+                const hawk = 'hawk';
             }
             
-            console.log('ddd');
-            console.log('eee');
-            console.log('yyy');
-            
-            test();
+            const eagle = 'eagle';
         `,
         {
             ...NO_ADDITIONAL_NODES_PRESET,
             compact: false,
             stringArray: true,
             stringArrayThreshold: 1,
-            stringArrayIntermediateVariablesCount: 10,
+            stringArrayIntermediateVariablesCount: 5,
             stringArrayEncoding: [
                 StringArrayEncoding.None
             ]

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.