ソースを参照

Performance boost

sanex3339 8 年 前
コミット
fe0e4b6114

ファイルの差分が大きいため隠しています
+ 173 - 199
dist/index.js


+ 1 - 1
src/cli/CLIUtils.ts

@@ -42,7 +42,7 @@ export class CLIUtils {
      */
     public static getOutputSourceMapPath (outputCodePath: string, sourceMapFileName: string = ''): string {
         if (sourceMapFileName) {
-            outputCodePath = `${outputCodePath.substr(
+            outputCodePath = `${outputCodePath.substring(
                 0, outputCodePath.lastIndexOf('/')
             )}/${sourceMapFileName}`;
         }

+ 1 - 1
src/node-transformers/obfuscating-transformers/replacers/IdentifierReplacer.ts

@@ -58,7 +58,7 @@ export class IdentifierReplacer extends AbstractReplacer implements IObfuscation
     private isReservedName (name: string): boolean {
         return this.options.reservedNames
             .some((reservedName: string) => {
-                return new RegExp(reservedName, 'g').test(name);
+                return new RegExp(reservedName, 'g').exec(name) !== null;
             });
     }
 }

+ 5 - 5
src/utils/Utils.ts

@@ -62,7 +62,7 @@ export class Utils {
     public static decToHex (dec: number): string {
         const radix: number = 16;
 
-        return Number(dec).toString(radix);
+        return dec.toString(radix);
     }
 
     /**
@@ -150,16 +150,16 @@ export class Utils {
             template: string;
 
         const result: string = string.replace(replaceRegExp, (escape: string): string => {
-            if (nonLatinAndNonDigitsOnly && !escapeRegExp.test(escape)) {
+            if (nonLatinAndNonDigitsOnly && !escapeRegExp.exec(escape)) {
                 return escape;
             }
 
-            if (regexp.test(escape)) {
+            if (regexp.exec(escape)) {
                 prefix = '\\x';
-                template = '0'.repeat(2);
+                template = '00';
             } else {
                 prefix = '\\u';
-                template = '0'.repeat(4);
+                template = '0000';
             }
 
             return `${prefix}${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`;

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません