Merge pull request #808 from sindresorhus/modularize-trimright
modularize `util.trimRight`
This commit is contained in:
commit
f24ae6feab
@ -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)) {
|
||||
|
||||
@ -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(",") : [];
|
||||
};
|
||||
|
||||
@ -61,7 +61,8 @@
|
||||
"repeating": "^1.1.2",
|
||||
"source-map": "^0.1.43",
|
||||
"source-map-support": "^0.2.9",
|
||||
"source-map-to-comment": "^1.0.0"
|
||||
"source-map-to-comment": "^1.0.0",
|
||||
"trim-right": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^8.1.3",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user