-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.JSBunDles.js
More file actions
65 lines (52 loc) · 1.58 KB
/
string.JSBunDles.js
File metadata and controls
65 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Object.defineProperties(
Object.prototype,
{
toInt: function(){
return Math.round(this.toFloat());
},
toFloat: function(){
return parseFloat(this);
},
isNumeric: function(){
return parseInt(this) == this || parseFloat(this) == this;
},
ucFirst: function(){
return this[0].toUpperCase() + this.substr(1);
},
lPad: function(length, char_){
if(!char_){
char_ = ' ';
}
if(length <= this.length){
return this.toString();
}
return new Array(length - this.length + 1).join(char_) + this;
},
rPad: function(length, char_){
if(!char_){
char_ = ' ';
}
if(length <= this.length){
return this.toString();
}
return this + new Array(length - this.length + 1).join(char_);
},
contains: function(string){
return this.indexOf(string) !== -1;
},
startsWith: function(string){
return this.indexOf(string) === 0;
},
endsWith: function(string){
return this.substr(this.length - string.length) === string;
},
equalsOne: function(){
for(var i in arguments){
if(arguments[i] == this){
return true;
}
}
return false;
}
}
);