diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-08-25 10:10:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 10:10:56 +0800 |
commit | 1caf7c7bd2160a5f249066bf62292f3589ceebb1 (patch) | |
tree | f3c2c7acbfe4655f94718d425c9641f5d4a3ca04 /lib/output.js | |
parent | 0eb0c9b388a17fbadd9f74a15effe7477695d5e6 (diff) | |
download | tracifyjs-1caf7c7bd2160a5f249066bf62292f3589ceebb1.tar.gz tracifyjs-1caf7c7bd2160a5f249066bf62292f3589ceebb1.zip |
minor clean up (#4069)
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/output.js b/lib/output.js index 82610fb6..cf05e261 100644 --- a/lib/output.js +++ b/lib/output.js @@ -100,7 +100,7 @@ function OutputStream(options) { } } - var indentation = 0; + var indentation = options.indent_start; var current_col = 0; var current_line = 1; var current_pos = 0; @@ -191,10 +191,6 @@ function OutputStream(options) { return name; } - function make_indent(back) { - return repeat_string(" ", options.indent_start + indentation - back * options.indent_level); - } - /* -----[ beautification/minification ]----- */ var has_parens = false; @@ -345,9 +341,7 @@ function OutputStream(options) { }; var indent = options.beautify ? function(half) { - if (options.beautify) { - print(make_indent(half ? 0.5 : 0)); - } + print(repeat_string(" ", half ? indentation - (options.indent_level >> 1) : indentation)); } : noop; var with_indent = options.beautify ? function(col, cont) { @@ -575,9 +569,9 @@ function OutputStream(options) { get : get, toString : get, indent : indent, - indentation : function() { return indentation }, - current_width : function() { return current_col - indentation }, - should_break : function() { return options.width && this.current_width() >= options.width }, + should_break : readonly ? noop : function() { + return options.width && current_col - indentation >= options.width; + }, has_parens : function() { return has_parens }, newline : newline, print : print, |