Skip to content

Commit

Permalink
Merge pull request #2085 from JedWatson/update/replace-trim-fn
Browse files Browse the repository at this point in the history
replace trim fn loop with regex
  • Loading branch information
gwyneplaine committed Oct 23, 2017
2 parents c89e5b3 + 342136a commit 2275ada
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utils/trim.js
Original file line number Diff line number Diff line change
@@ -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 2275ada

Please sign in to comment.