Skip to content

Commit

Permalink
use native methods when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
yields committed Jun 27, 2013
1 parent cf9e348 commit f8a1bd7
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 f8a1bd7

Please sign in to comment.