mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
added const
This commit is contained in:
Vendored
+7
-2
@@ -21,7 +21,11 @@ class Utils {
|
||||
return newArray;
|
||||
}
|
||||
static decToHex(dec) {
|
||||
return (dec + Math.pow(16, 6)).toString(16).substr(-6).replace(Utils.hexRepetitiveZerosRegExp, '');
|
||||
const decToHexSliceValue = -6, exponent = 6, radix = 16;
|
||||
return (dec + Math.pow(radix, exponent))
|
||||
.toString(radix)
|
||||
.substr(decToHexSliceValue)
|
||||
.replace(Utils.hexRepetitiveZerosRegExp, '');
|
||||
}
|
||||
static getRandomInteger(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
@@ -37,8 +41,9 @@ class Utils {
|
||||
return obj;
|
||||
}
|
||||
static stringToUnicode(string) {
|
||||
const radix = 16, unicodeSliceValue = -4;
|
||||
return `'${string.replace(/[\s\S]/g, (escape) => {
|
||||
return `\\u${('0000' + escape.charCodeAt(0).toString(16)).slice(-4)}`;
|
||||
return `\\u${('0000' + escape.charCodeAt(0).toString(radix)).slice(unicodeSliceValue)}`;
|
||||
})}'`;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-2
@@ -45,7 +45,14 @@ export class Utils {
|
||||
* @returns {string}
|
||||
*/
|
||||
public static decToHex(dec: number): string {
|
||||
return (dec + Math.pow(16, 6)).toString(16).substr(-6).replace(Utils.hexRepetitiveZerosRegExp, '');
|
||||
const decToHexSliceValue: number = -6,
|
||||
exponent: number = 6,
|
||||
radix: number = 16;
|
||||
|
||||
return (dec + Math.pow(radix, exponent))
|
||||
.toString(radix)
|
||||
.substr(decToHexSliceValue)
|
||||
.replace(Utils.hexRepetitiveZerosRegExp, '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,8 +97,11 @@ export class Utils {
|
||||
* @returns {string}
|
||||
*/
|
||||
public static stringToUnicode (string: string): string {
|
||||
const radix: number = 16,
|
||||
unicodeSliceValue: number = -4;
|
||||
|
||||
return `'${string.replace(/[\s\S]/g, (escape: string): string => {
|
||||
return `\\u${('0000' + escape.charCodeAt(0).toString(16)).slice(-4)}`;
|
||||
return `\\u${('0000' + escape.charCodeAt(0).toString(radix)).slice(unicodeSliceValue)}`;
|
||||
})}'`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user