Simplify the String::trim polyfill.
Showing
2 changed files
with
3 additions
and
4 deletions
... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
8 | 8 | ||
9 | if (!String.prototype.trim) { | 9 | if (!String.prototype.trim) { |
10 | String.prototype.trim = function() { | 10 | String.prototype.trim = function() { |
11 | return this.replace(/^\s\*/, '').replace(/\s\s*$/, ''); | 11 | return this.replace(/^\s+|\s+$/g, ""); |
12 | }; | 12 | }; |
13 | } | 13 | } |
14 | 14 | ... | ... |
... | @@ -6,9 +6,8 @@ | ... | @@ -6,9 +6,8 @@ |
6 | # The Rivets namespace. | 6 | # The Rivets namespace. |
7 | Rivets = {} | 7 | Rivets = {} |
8 | 8 | ||
9 | # Polyfill For String::trim | 9 | # Polyfill For String::trim. |
10 | unless String::trim | 10 | unless String::trim then String::trim = -> @replace /^\s+|\s+$/g, "" |
11 | String::trim = -> return @.replace(/^\s\*/, '').replace(/\s\s*$/, '') | ||
12 | 11 | ||
13 | # Polyfill For Array::map | 12 | # Polyfill For Array::map |
14 | unless Array::map | 13 | unless Array::map | ... | ... |
-
Please register or sign in to post a comment