lib/uglify.js in uglifier-1.2.5 vs lib/uglify.js in uglifier-1.2.6

- old
+ new

@@ -1,22 +1,22 @@ (function(global) { (function(/*! Stitch !*/) { if (!this.require) { var modules = {}, cache = {}, require = function(name, root) { - var path = expand(root, name), module = cache[path], fn; + var module = cache[name], path = expand(root, name), fn; if (module) { - return module.exports; + return module; } else if (fn = modules[path] || modules[path = expand(path, './index')]) { - module = {id: path, exports: {}}; + module = {id: name, exports: {}}; try { - cache[path] = module; + cache[name] = module.exports; fn(module.exports, function(name) { return require(name, dirname(path)); }, module); - return module.exports; + return cache[name] = module.exports; } catch (err) { - delete cache[path]; + delete cache[name]; throw err; } } else { throw 'module \'' + name + '\' not found'; } @@ -2625,10 +2625,12 @@ exports.RESERVED_WORDS = RESERVED_WORDS; exports.KEYWORDS = KEYWORDS; exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN; exports.OPERATORS = OPERATORS; exports.is_alphanumeric_char = is_alphanumeric_char; +exports.is_identifier_start = is_identifier_start; +exports.is_identifier_char = is_identifier_char; exports.set_logger = function(logger) { warn = logger; }; }, "process": function(exports, require, module) {/*********************************************************************** @@ -2691,10 +2693,11 @@ ***********************************************************************/ var jsp = require("./parse-js"), slice = jsp.slice, member = jsp.member, + is_identifier_char = jsp.is_identifier_char, PRECEDENCE = jsp.PRECEDENCE, OPERATORS = jsp.OPERATORS; /* -----[ helper for AST traversal ]----- */ @@ -4147,18 +4150,28 @@ indentation += incr; try { return cont.apply(null, slice(arguments, 1)); } finally { indentation -= incr; } }; + function last_char(str) { + str = str.toString(); + return str.charAt(str.length - 1); + }; + + function first_char(str) { + return str.toString().charAt(0); + }; + function add_spaces(a) { if (beautify) return a.join(" "); var b = []; for (var i = 0; i < a.length; ++i) { var next = a[i + 1]; b.push(a[i]); if (next && - ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) || + ((is_identifier_char(last_char(a[i])) && (is_identifier_char(first_char(next)) + || first_char(next) == "\\")) || (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) { b.push(" "); } } return b.join("");