diff --git a/index.js b/index.js index 640c24c..36e7e5d 100644 --- a/index.js +++ b/index.js @@ -2,13 +2,16 @@ exports = module.exports = trim; function trim(str){ + if (str.trim) return str.trim(); return str.replace(/^\s*|\s*$/g, ''); } exports.left = function(str){ + if (str.trimLeft) return str.trimLeft(); return str.replace(/^\s*/, ''); }; exports.right = function(str){ + if (str.trimRight) return str.trimRight(); return str.replace(/\s*$/, ''); };