Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Belgian Biodiversity Platform
yeti
Commits
31a50e8e
Commit
31a50e8e
authored
Jul 11, 2012
by
Julien Cigar
Browse files
added String.trim
parent
339e20c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
core.js
View file @
31a50e8e
...
...
@@ -30,8 +30,12 @@
acceptable.
************************************************************************/
/* This is taken from https://developer.mozilla.org and is exactly the
* one specified in ECMA-262.
/* Array.indexOf
* Returns the first (least) index of an element within the array equal
* to the specified value, or -1 if none is found.
*
* Implementation is taken from https://developer.mozilla.org and is
* exactly the one specified in ECMA-262.
*/
if
(
!
Array
.
prototype
.
indexOf
)
{
...
...
@@ -76,8 +80,12 @@
}
}
/* This is taken from https://developer.mozilla.org and is exactly the
* one specified in ECMA-262.
/* Array.lastIndexOf
* Returns the last (greatest) index of an element within the array equal
* to the specified value, or -1 if none is found.
*
* Implementation is taken from https://developer.mozilla.org and is
* exactly the one specified in ECMA-262.
*/
if
(
!
Array
.
prototype
.
lastIndexOf
)
{
...
...
@@ -118,6 +126,16 @@
};
}
/* String.trim
* Removes whitespace from both ends of the string.
*/
if
(
!
String
.
prototype
.
trim
)
{
String
.
prototype
.
trim
=
function
()
{
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
''
);
};
}
/***********************************************************************
Str
...
...
@@ -125,16 +143,6 @@
Yeti
.
Str
=
new
Object
()
/* Yeti.Str.trim
* Returns the string stripped of whitespace from both ends.
*/
Yeti
.
Str
.
trim
=
function
(
src
)
{
return
src
.
trim
?
src
.
trim
()
:
src
.
replace
(
/^
\s
+|
\s
+$/g
,
''
);
}
/* Yeti.Str.reverse
* Returns the string reversed.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment