File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ String . prototype . contains = function ( text ) {
2+ if ( text == '' ) return true ;
3+ else if ( text == null ) return false ;
4+ else return this . indexOf ( text ) !== - 1 ;
5+ }
6+ String . prototype . count = function ( text ) {
7+ if ( this . contains ( text ) ) {
8+ return this . split ( text ) . length - 1 ;
9+ }
10+ else
11+ return 0 ;
12+ }
13+ String . prototype . capitalize = function ( ) {
14+ if ( this == '' ) return str ;
15+ else return this . charAt ( 0 ) . toUpperCase ( ) + this . slice ( 1 ) ;
16+ }
17+ String . prototype . clear = function ( ) {
18+ return this . trim ( ) . replace ( / \s + / g, ' ' ) ;
19+ }
20+ String . prototype . endsWith = function ( text ) {
21+ if ( text == '' ) return true ;
22+ else if ( text == null ) return false ;
23+ else return this . indexOf ( text , this . length - text . length ) !== - 1 ;
24+ }
25+
26+ String . prototype . insert = function ( text , at ) {
27+ if ( at == null || at > this . length )
28+ at = this . length ;
29+ else if ( at < 0 )
30+ at = 0 ;
31+
32+ return this . substring ( 0 , at ) + text + this . substring ( at ) ;
33+ }
You can’t perform that action at this time.
0 commit comments