From 5811d649cdeeee3c4561d2f93b6af31b4af2806f Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Sun, 7 Jun 2020 18:11:01 +0300 Subject: [PATCH] Updated README.md #3 --- README.md | 38 +++++++++++++++++++++----------------- test/dev/dev.ts | 20 +++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index c4d14a1d..f544aae4 100644 --- a/README.md +++ b/README.md @@ -685,25 +685,29 @@ To control which properties will be renamed use [`reservedNames`](#reservedNames Example: ```ts // input -const foo = { - prop1: 1, - prop2: 2, - calc: function () { - return this.prop1 + this.prop2; - } -}; - -console.log(foo.calc()); +(function () { + const foo = { + prop1: 1, + prop2: 2, + calc: function () { + return this.prop1 + this.prop2; + } + }; + + console.log(foo.calc()); +})(); // output -const foo = { - '_0x5a9b25': 0x1, - '_0x8ea4ee': 0x2, - '_0x2fe16b': function () { - return this['_0x5a9b25'] + this['_0x8ea4ee']; - } -}; -console['log'](foo['_0x2fe16b']()); +(function () { + const _0x46529b = { + '_0x10cec7': 0x1, + '_0xc1c0ca': 0x2, + '_0x4b961d': function () { + return this['_0x10cec7'] + this['_0xc1c0ca']; + } + }; + console['log'](_0x46529b['_0x4b961d']()); +}()); ``` ### `reservedNames` diff --git a/test/dev/dev.ts b/test/dev/dev.ts index be33446a..5e6ba1f6 100644 --- a/test/dev/dev.ts +++ b/test/dev/dev.ts @@ -7,15 +7,17 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( ` - const foo = { - prop1: 1, - prop2: 2, - calc: function () { - return this.prop1 + this.prop2; - } - }; - - console.log(foo.calc()); + (function () { + const foo = { + prop1: 1, + prop2: 2, + calc: function () { + return this.prop1 + this.prop2; + } + }; + + console.log(foo.calc()); + })(); `, { ...NO_ADDITIONAL_NODES_PRESET,