diff --git a/lib/6to5/generator.js b/lib/6to5/generator.js index c3ba631a88..6f48131261 100644 --- a/lib/6to5/generator.js +++ b/lib/6to5/generator.js @@ -70,7 +70,7 @@ CodeGenerator.prototype.push = function (str) { str = str.replace(/\n/g, "\n" + indent); // we've got a newline before us so prepend on the indentation - if (_.last(this.buf) === "\n") str = indent + str; + if (this.isLast("\n")) str = indent + str; } var self = this; @@ -87,6 +87,10 @@ CodeGenerator.prototype.push = function (str) { this.buf += str; }; +CodeGenerator.prototype.isLast = function (cha) { + return _.last(this.buf) === cha; +}; + CodeGenerator.prototype.getIndent = function () { return util.repeat(this._indent * this.tabWidth); };