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

@ -1,26 +0,0 @@
"use strict";
// Polyfills for browsers that do not support String.trimLeft/Right
function trimLeftPolyfill() {
return this.replace(/^\s*/, "");
}
/* istanbul ignore if */
if (!String.prototype.trimLeft) {
String.prototype.trimLeft = trimLeftPolyfill;
}
function trimRightPolyfill() {
return this.replace(/\s*$/, "");
}
/* istanbul ignore if */
if (!String.prototype.trimRight) {
String.prototype.trimRight = trimRightPolyfill;
}
// Export for testing
/* istanbul ignore else */
if ((typeof module !== "undefined") && module.exports) {
module.exports = {
"trimLeftPolyfill": trimLeftPolyfill,
"trimRightPolyfill": trimRightPolyfill
};
}