Skip to content

Commit

Permalink
replace trim fn loop with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
gwyneplaine committed Oct 23, 2017
1 parent c89e5b3 commit 342136a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utils/trim.js
@@ -1,10 +1,3 @@
module.exports = function trim(str) {
str = str.replace(/^\s+/, '');
for (var i = str.length - 1; i >= 0; i--) {
if (/\S/.test(str.charAt(i))) {
str = str.substring(0, i + 1);
break;
}
}
return str;
};
return str.replace(/^\s+|\s+$/g, '');
};

0 comments on commit 342136a

Please sign in to comment.