dev.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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. import { StringArrayWrappersType } from '../../src/enums/node-transformers/string-array-transformers/StringArrayWrappersType';
  5. (function () {
  6. const JavaScriptObfuscator: any = require('../../index');
  7. let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
  8. `
  9. const foo = 'foo';
  10. function test () {
  11. const bar = 'bar';
  12. }
  13. `,
  14. {
  15. ...NO_ADDITIONAL_NODES_PRESET,
  16. compact: false,
  17. forceTransformedStrings: ['foo'],
  18. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  19. stringArray: true,
  20. stringArrayThreshold: 0,
  21. stringArrayWrappersChainedCalls: true,
  22. stringArrayWrappersCount: 1,
  23. stringArrayWrappersType: StringArrayWrappersType.Function
  24. }
  25. ).getObfuscatedCode();
  26. console.log(obfuscatedCode);
  27. console.log(eval(obfuscatedCode));
  28. })();