aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/output.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/output.js b/lib/output.js
index dd40972e..8d2c4d39 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -58,6 +58,7 @@ function OutputStream(options) {
beautify : false,
source_map : null,
bracketize : false,
+ semicolons : true,
comments : false
}, true);
@@ -130,14 +131,23 @@ function OutputStream(options) {
print("\n");
};
+ var requireSemicolonChars = makePredicate("( [ + * / - , .");
+
function print(str) {
str = String(str);
var ch = str.charAt(0);
if (might_need_semicolon) {
if (";}".indexOf(ch) < 0 && !/[;]$/.test(last)) {
- OUTPUT += ";";
- current_col++;
- current_pos++;
+ if (options.semicolons || requireSemicolonChars(ch)) {
+ OUTPUT += ";";
+ current_col++;
+ current_pos++;
+ } else {
+ OUTPUT += "\n";
+ current_pos++;
+ current_line++;
+ current_col = 0;
+ }
if (!options.beautify)
might_need_space = false;
}