dev.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
  3. import { IdentifierNamesGenerator } from '../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
  4. (function () {
  5. const JavaScriptObfuscator: any = require('../../index');
  6. let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
  7. `
  8. const foo = 'foo'
  9. const bar = 'bar';
  10. const baz = 'baz';
  11. function test () {
  12. const bark = 'bark'
  13. const hawk = 'hawk';
  14. const eagle = 'eagle';
  15. }
  16. `,
  17. {
  18. ...NO_ADDITIONAL_NODES_PRESET,
  19. compact: false,
  20. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  21. renameGlobals: true,
  22. stringArray: true,
  23. transformObjectKeys: true,
  24. stringArrayThreshold: 1,
  25. stringArrayWrappersChainedCalls: false,
  26. stringArrayWrappersCount: 2
  27. }
  28. ).getObfuscatedCode();
  29. console.log(obfuscatedCode);
  30. console.log(eval(obfuscatedCode));
  31. })();