Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1288)

Unified Diff: src/string.js

Issue 266050: Add trim, trimLeft and trimRight methods to String (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/string.js
===================================================================
--- src/string.js (revision 3045)
+++ src/string.js (working copy)
@@ -680,7 +680,19 @@
return %StringToUpperCase(ToString(this));
}
+// ES5, 15.5.4.20
+function StringTrim() {
+ return %StringTrim(ToString(this), true, true);
+}
+function StringTrimLeft() {
+ return %StringTrim(ToString(this), true, false);
+}
+
+function StringTrimRight() {
+ return %StringTrim(ToString(this), false, true);
+}
+
// ECMA-262, section 15.5.3.2
function StringFromCharCode(code) {
var n = %_ArgumentsLength();
@@ -855,6 +867,9 @@
"toLocaleLowerCase", StringToLocaleLowerCase,
"toUpperCase", StringToUpperCase,
"toLocaleUpperCase", StringToLocaleUpperCase,
+ "trim", StringTrim,
+ "trimLeft", StringTrimLeft,
+ "trimRight", StringTrimRight,
"link", StringLink,
"anchor", StringAnchor,
"fontcolor", StringFontcolor,

Powered by Google App Engine
This is Rietveld 408576698