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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 function StringToUpperCase() { 673 function StringToUpperCase() {
674 return %StringToUpperCase(ToString(this)); 674 return %StringToUpperCase(ToString(this));
675 } 675 }
676 676
677 677
678 // ECMA-262, 15.5.4.19 678 // ECMA-262, 15.5.4.19
679 function StringToLocaleUpperCase() { 679 function StringToLocaleUpperCase() {
680 return %StringToUpperCase(ToString(this)); 680 return %StringToUpperCase(ToString(this));
681 } 681 }
682 682
683 // ES5, 15.5.4.20
684 function StringTrim() {
685 return %StringTrim(ToString(this), true, true);
686 }
687
688 function StringTrimLeft() {
689 return %StringTrim(ToString(this), true, false);
690 }
691
692 function StringTrimRight() {
693 return %StringTrim(ToString(this), false, true);
694 }
683 695
684 // ECMA-262, section 15.5.3.2 696 // ECMA-262, section 15.5.3.2
685 function StringFromCharCode(code) { 697 function StringFromCharCode(code) {
686 var n = %_ArgumentsLength(); 698 var n = %_ArgumentsLength();
687 if (n == 1) return %CharFromCode(ToNumber(code) & 0xffff) 699 if (n == 1) return %CharFromCode(ToNumber(code) & 0xffff)
688 700
689 // NOTE: This is not super-efficient, but it is necessary because we 701 // NOTE: This is not super-efficient, but it is necessary because we
690 // want to avoid converting to numbers from within the virtual 702 // want to avoid converting to numbers from within the virtual
691 // machine. Maybe we can find another way of doing this? 703 // machine. Maybe we can find another way of doing this?
692 var codes = new $Array(n); 704 var codes = new $Array(n);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 "replace", StringReplace, 860 "replace", StringReplace,
849 "search", StringSearch, 861 "search", StringSearch,
850 "slice", StringSlice, 862 "slice", StringSlice,
851 "split", StringSplit, 863 "split", StringSplit,
852 "substring", StringSubstring, 864 "substring", StringSubstring,
853 "substr", StringSubstr, 865 "substr", StringSubstr,
854 "toLowerCase", StringToLowerCase, 866 "toLowerCase", StringToLowerCase,
855 "toLocaleLowerCase", StringToLocaleLowerCase, 867 "toLocaleLowerCase", StringToLocaleLowerCase,
856 "toUpperCase", StringToUpperCase, 868 "toUpperCase", StringToUpperCase,
857 "toLocaleUpperCase", StringToLocaleUpperCase, 869 "toLocaleUpperCase", StringToLocaleUpperCase,
870 "trim", StringTrim,
871 "trimLeft", StringTrimLeft,
872 "trimRight", StringTrimRight,
858 "link", StringLink, 873 "link", StringLink,
859 "anchor", StringAnchor, 874 "anchor", StringAnchor,
860 "fontcolor", StringFontcolor, 875 "fontcolor", StringFontcolor,
861 "fontsize", StringFontsize, 876 "fontsize", StringFontsize,
862 "big", StringBig, 877 "big", StringBig,
863 "blink", StringBlink, 878 "blink", StringBlink,
864 "bold", StringBold, 879 "bold", StringBold,
865 "fixed", StringFixed, 880 "fixed", StringFixed,
866 "italics", StringItalics, 881 "italics", StringItalics,
867 "small", StringSmall, 882 "small", StringSmall,
868 "strike", StringStrike, 883 "strike", StringStrike,
869 "sub", StringSub, 884 "sub", StringSub,
870 "sup", StringSup, 885 "sup", StringSup,
871 "toJSON", StringToJSON 886 "toJSON", StringToJSON
872 )); 887 ));
873 } 888 }
874 889
875 890
876 SetupString(); 891 SetupString();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698