Replace trimLeft/trimRight polyfills with helper methods.

This commit is contained in:
David Anson 2017-12-13 21:41:28 -08:00
parent 39d39db961
commit 1184281c87
5 changed files with 21 additions and 36 deletions

View file

@ -14,6 +14,18 @@ module.exports.inlineCommentRe = inlineCommentRe;
// readFile options for reading with the UTF-8 encoding
module.exports.utf8Encoding = { "encoding": "utf8" };
// Trims whitespace from the left (start) of a string
function trimLeft(str) {
return str.replace(/^\s*/, "");
}
module.exports.trimLeft = trimLeft;
// Trims whitespace from the right (end) of a string
function trimRight(str) {
return str.replace(/\s*$/, "");
}
module.exports.trimRight = trimRight;
// Applies key/value pairs from src to dst, returning dst
function assign(dst, src) {
Object.keys(src).forEach(function forKey(key) {