return repeat_string(" ", options.indent_start + indentation - back * options.indent_level);
};
- function last_char() {
- return OUTPUT.charAt(OUTPUT.length - 1);
- };
-
/* -----[ beautification/minification ]----- */
var might_need_space = false;
var might_need_semicolon = false;
var last = null;
+ function last_char() {
+ return last.charAt(last.length - 1);
+ };
+
function print(str) {
- last = str;
str = String(str);
var ch = str.charAt(0);
if (might_need_semicolon) {
- if (";}".indexOf(ch) < 0 && !/[;]$/.test(OUTPUT)) {
+ if (";}".indexOf(ch) < 0 && !/[;]$/.test(last)) {
OUTPUT += ";";
current_col++;
current_pos++;
if ((is_identifier_char(last_char())
&& (is_identifier_char(ch) || ch == "\\"))
||
- (/[\+\-]$/.test(OUTPUT) && /^[\+\-]/.test(str)))
+ (/[\+\-]$/.test(last) && /^[\+\-]/.test(str)))
{
OUTPUT += " ";
current_col++;
current_col += a[n - 1].length;
}
current_pos += str.length;
+ last = str;
OUTPUT += str;
};
output.print("]");
});
DEFPRINT(AST_UnaryPrefix, function(self, output){
- output.print(self.operator);
- if (is_alphanumeric_char(self.operator.charAt(0)))
+ var op = self.operator;
+ output.print(op);
+ if (/^[a-z]/i.test(op))
output.space();
self.expression.print(output);
});