This repository was archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathExtensions.js
More file actions
53 lines (50 loc) · 1.61 KB
/
Extensions.js
File metadata and controls
53 lines (50 loc) · 1.61 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
export var StringFunctions = {
startsWith: function () {
var self, str;
if (arguments.length == 2) {
self = arguments[0];
str = arguments[1];
} else if (arguments.length == 1 && typeof this === 'string') {
self = this;
str = arguments[0];
} else if (this instanceof String) {
self = this.valueOf();
str = arguments[0];
} else
return false;
if (typeof self !== 'string') return false;
return self.indexOf(str) === 0;
},
endsWith: function () {
var self, str;
if (arguments.length == 2) {
self = arguments[0];
str = arguments[1];
} else if (arguments.length == 1 && typeof this === 'string') {
self = this;
str = arguments[0];
} else if (this instanceof String) {
self = this.valueOf();
str = arguments[0];
} else
return false;
if (typeof self !== 'string') return false;
return self.slice(-str.length) === str;
},
contains: function () {
var self, str;
if (arguments.length == 2) {
self = arguments[0];
str = arguments[1];
} else if (arguments.length == 1 && typeof this === 'string') {
self = this;
str = arguments[0];
} else if (this instanceof String) {
self = this.valueOf();
str = arguments[0];
} else
return false;
if (typeof self !== 'string') return false;
return self.indexOf(str) >= 0;
}
};