Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
1b2c90bc
authored
2012-07-09 21:58:49 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Simplify the String::trim polyfill.
1 parent
d582ba6a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
4 deletions
lib/rivets.js
src/rivets.coffee
lib/rivets.js
View file @
1b2c90b
...
...
@@ -8,7 +8,7 @@
if
(
!
String
.
prototype
.
trim
)
{
String
.
prototype
.
trim
=
function
()
{
return
this
.
replace
(
/^
\s
\*
/
,
''
).
replace
(
/
\s\s
*$/
,
''
);
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
};
}
...
...
src/rivets.coffee
View file @
1b2c90b
...
...
@@ -6,9 +6,8 @@
# The Rivets namespace.
Rivets
=
{}
# Polyfill For String::trim
unless
String
::
trim
String
::
trim
=
->
return
@
.
replace
(
/^\s\*/
,
''
).
replace
(
/\s\s*$/
,
''
)
# Polyfill For String::trim.
unless
String
::
trim
then
String
::
trim
=
->
@
replace
/^\s+|\s+$/g
,
""
# Polyfill For Array::map
unless
Array
::
map
...
...
Please
register
or
sign in
to post a comment