add util.trimRight method - fixes #147

This commit is contained in:
Sebastian McKenzie 2014-11-12 12:17:26 +11:00
parent ae439d27b9
commit 896929378e
2 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,7 @@ function Buffer(position, format) {
}
Buffer.prototype.get = function () {
return this.buf.trimRight();
return util.trimRight(this.buf);
};
Buffer.prototype.getIndent = function () {
@ -116,7 +116,7 @@ Buffer.prototype.endsWith = function (str) {
Buffer.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = buf.trimRight();
if (trimRight) buf = util.trimRight(buf);
var chars = [].concat(cha);
return _.contains(chars, _.last(buf));

View File

@ -25,6 +25,10 @@ exports.resolve = function (loc) {
}
};
exports.trimRight = function (str) {
return str.replace(/[\n\s]+$/g, "");
};
exports.list = function (val) {
return val ? val.split(",") : [];
};