modularize util.trimRight

https://github.com/sindresorhus/trim-right
This commit is contained in:
Sindre Sorhus
2015-02-17 10:50:30 +07:00
parent 28c948e5ea
commit 5b09114b85
3 changed files with 6 additions and 9 deletions

View File

@@ -3,10 +3,10 @@
module.exports = Buffer;
var repeating = require("repeating");
var trimRight = require("trim-right");
var isBoolean = require("lodash/lang/isBoolean");
var includes = require("lodash/collection/includes");
var isNumber = require("lodash/lang/isNumber");
var util = require("../util");
function Buffer(position, format) {
this.position = position;
@@ -16,7 +16,7 @@ function Buffer(position, format) {
}
Buffer.prototype.get = function () {
return util.trimRight(this.buf);
return trimRight(this.buf);
};
Buffer.prototype.getIndent = function () {
@@ -154,9 +154,9 @@ Buffer.prototype.endsWith = function (str) {
return d >= 0 && this.buf.lastIndexOf(str) === d;
};
Buffer.prototype.isLast = function (cha, trimRight) {
Buffer.prototype.isLast = function (cha, shouldTrimRight) {
var buf = this.buf;
if (trimRight) buf = util.trimRight(buf);
if (shouldTrimRight) buf = trimRight(buf);
var last = buf[buf.length - 1];
if (Array.isArray(cha)) {

View File

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