Move unescaping regexps under a codegen option (`unescape_regexps`)
authorMihai Bazon <mihai@bazon.net>
Sun, 26 Jan 2014 08:05:55 +0000 (10:05 +0200)
committerMihai Bazon <mihai@bazon.net>
Sun, 26 Jan 2014 08:05:55 +0000 (10:05 +0200)
lib/output.js

index c2f49e9..5503903 100644 (file)
 function OutputStream(options) {
 
     options = defaults(options, {
-        indent_start  : 0,
-        indent_level  : 4,
-        quote_keys    : false,
-        space_colon   : true,
-        ascii_only    : false,
-        inline_script : false,
-        width         : 80,
-        max_line_len  : 32000,
-        beautify      : false,
-        source_map    : null,
-        bracketize    : false,
-        semicolons    : true,
-        comments      : false,
-        preserve_line : false,
-        screw_ie8     : false,
-        preamble      : null,
+        indent_start     : 0,
+        indent_level     : 4,
+        quote_keys       : false,
+        space_colon      : true,
+        ascii_only       : false,
+        unescape_regexps : false,
+        inline_script    : false,
+        width            : 80,
+        max_line_len     : 32000,
+        beautify         : false,
+        source_map       : null,
+        bracketize       : false,
+        semicolons       : true,
+        comments         : false,
+        preserve_line    : false,
+        screw_ie8        : false,
+        preamble         : null,
     }, true);
 
     var indentation = 0;
@@ -1150,7 +1151,7 @@ function OutputStream(options) {
         var str = self.getValue().toString();
         if (output.option("ascii_only")) {
             str = output.to_ascii(str);
-        } else {
+        } else if (output.option("unescape_regexps")) {
             str = str.split("\\\\").map(function(str){
                 return str.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g, function(s){
                     var code = parseInt(s.substr(2), 16);