Skip to content

Commit

Permalink
Merge pull request #2 from yields/master
Browse files Browse the repository at this point in the history
use native methods when possible.
  • Loading branch information
jonathanong committed Oct 9, 2013
2 parents b8358a4 + f8a1bd7 commit d483c42
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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*$/, '');
};

0 comments on commit d483c42

Please sign in to comment.