Pārlūkot izejas kodu

Pass `simplify` and `numbersToExpressions` options to CustomCodeHelperObfuscator obfuscation

sanex3339 4 gadi atpakaļ
vecāks
revīzija
19fa1fb602

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/index.browser.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/index.cli.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/index.js


+ 2 - 0
src/custom-code-helpers/CustomCodeHelperObfuscator.ts

@@ -47,6 +47,8 @@ export class CustomCodeHelperObfuscator implements ICustomCodeHelperObfuscator {
                 ...NO_ADDITIONAL_NODES_PRESET,
                 ...NO_ADDITIONAL_NODES_PRESET,
                 identifierNamesGenerator: this.options.identifierNamesGenerator,
                 identifierNamesGenerator: this.options.identifierNamesGenerator,
                 identifiersDictionary: this.options.identifiersDictionary,
                 identifiersDictionary: this.options.identifiersDictionary,
+                numbersToExpressions: this.options.numbersToExpressions,
+                simplify: this.options.simplify,
                 seed: this.randomGenerator.getRawSeed(),
                 seed: this.randomGenerator.getRawSeed(),
                 ...additionalOptions
                 ...additionalOptions
             }
             }

+ 6 - 2
test/dev/dev.ts

@@ -8,12 +8,16 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
     let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
     let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
         `
         `
             const foo = 0;
             const foo = 0;
+            const bar = 'abc';
             
             
-            console.log(foo);
+            console.log(foo, bar);
         `,
         `,
         {
         {
             ...NO_ADDITIONAL_NODES_PRESET,
             ...NO_ADDITIONAL_NODES_PRESET,
-            numbersToExpressions: true
+            compact: false,
+            numbersToExpressions: true,
+            stringArray: true,
+            stringArrayThreshold: 1
         }
         }
     ).getObfuscatedCode();
     ).getObfuscatedCode();
 
 

+ 3 - 1
test/unit-tests/utils/NumberUtils.spec.ts

@@ -2,7 +2,9 @@ import { assert } from 'chai';
 
 
 import { NumberUtils } from '../../../src/utils/NumberUtils';
 import { NumberUtils } from '../../../src/utils/NumberUtils';
 
 
-describe('NumberUtils', () => {
+describe('NumberUtils', function () {
+    this.timeout(30000);
+
     describe('toHex', () => {
     describe('toHex', () => {
         describe('Variant #1: number `0`', () => {
         describe('Variant #1: number `0`', () => {
             const number: number = 0;
             const number: number = 0;

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels