mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
refactoring
This commit is contained in:
Vendored
+7
-4
@@ -42,14 +42,17 @@ class Utils {
|
||||
}
|
||||
static stringToUnicode(string) {
|
||||
const radix = 16;
|
||||
let regexp = new RegExp('[\x00-\x7F]'), template;
|
||||
let prefix, regexp = new RegExp('[\x00-\x7F]'), template;
|
||||
return `'${string.replace(/[\s\S]/g, (escape) => {
|
||||
if (regexp.test(escape)) {
|
||||
prefix = '\\x';
|
||||
template = '0'.repeat(2);
|
||||
return `\\x${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;
|
||||
}
|
||||
template = '0'.repeat(4);
|
||||
return `\\u${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;
|
||||
else {
|
||||
prefix = '\\u';
|
||||
template = '0'.repeat(4);
|
||||
}
|
||||
return `${prefix}${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;
|
||||
})}'`;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,9 +4,9 @@ exports.DEFAULT_PRESET = Object.freeze({
|
||||
debugProtection: false,
|
||||
debugProtectionInterval: false,
|
||||
disableConsoleOutput: true,
|
||||
encodeUnicodeLiterals: false,
|
||||
reservedNames: [],
|
||||
rotateUnicodeArray: true,
|
||||
encodeUnicodeLiterals: false,
|
||||
unicodeArray: true,
|
||||
wrapUnicodeArrayCalls: true
|
||||
});
|
||||
|
||||
+1
-1
@@ -4,9 +4,9 @@ exports.NO_CUSTOM_NODES_PRESET = Object.freeze({
|
||||
debugProtection: false,
|
||||
debugProtectionInterval: false,
|
||||
disableConsoleOutput: false,
|
||||
encodeUnicodeLiterals: false,
|
||||
reservedNames: [],
|
||||
rotateUnicodeArray: false,
|
||||
encodeUnicodeLiterals: false,
|
||||
unicodeArray: false,
|
||||
wrapUnicodeArrayCalls: false
|
||||
});
|
||||
|
||||
+7
-6
@@ -99,19 +99,20 @@ export class Utils {
|
||||
public static stringToUnicode (string: string): string {
|
||||
const radix: number = 16;
|
||||
|
||||
let regexp: RegExp = new RegExp('[\x00-\x7F]'),
|
||||
let prefix: string,
|
||||
regexp: RegExp = new RegExp('[\x00-\x7F]'),
|
||||
template: string;
|
||||
|
||||
return `'${string.replace(/[\s\S]/g, (escape: string): string => {
|
||||
if (regexp.test(escape)) {
|
||||
prefix = '\\x';
|
||||
template = '0'.repeat(2);
|
||||
|
||||
return `\\x${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;
|
||||
} else {
|
||||
prefix = '\\u';
|
||||
template = '0'.repeat(4);
|
||||
}
|
||||
|
||||
template = '0'.repeat(4);
|
||||
|
||||
return `\\u${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;
|
||||
return `${prefix}${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;
|
||||
})}'`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ export const DEFAULT_PRESET: IOptions = Object.freeze({
|
||||
debugProtection: false,
|
||||
debugProtectionInterval: false,
|
||||
disableConsoleOutput: true,
|
||||
encodeUnicodeLiterals: false,
|
||||
reservedNames: [],
|
||||
rotateUnicodeArray: true,
|
||||
encodeUnicodeLiterals: false,
|
||||
unicodeArray: true,
|
||||
wrapUnicodeArrayCalls: true
|
||||
});
|
||||
|
||||
@@ -5,9 +5,9 @@ export const NO_CUSTOM_NODES_PRESET: IOptions = Object.freeze({
|
||||
debugProtection: false,
|
||||
debugProtectionInterval: false,
|
||||
disableConsoleOutput: false,
|
||||
encodeUnicodeLiterals: false,
|
||||
reservedNames: [],
|
||||
rotateUnicodeArray: false,
|
||||
encodeUnicodeLiterals: false,
|
||||
unicodeArray: false,
|
||||
wrapUnicodeArrayCalls: false
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user