dev.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  18. stringArray: true,
  19. stringArrayThreshold: 1,
  20. stringArrayWrappersChainedCalls: true,
  21. stringArrayWrappersCount: 1,
  22. stringArrayWrappersType: StringArrayWrappersType.Function
  23. }
  24. ).getObfuscatedCode();
  25. console.log(obfuscatedCode);
  26. console.log(eval(obfuscatedCode));
  27. })();