UNPKG

927 BJavaScriptView Raw
1if (!String.prototype.endsWith) {
2 Object.defineProperty(String.prototype, 'endsWith', {
3 enumerable: false,
4 configurable: false,
5 writable: false,
6 value: function (searchString, position) {
7 position = position || this.length;
8 position = position - searchString.length;
9 var lastIndex = this.lastIndexOf(searchString);
10 return lastIndex !== -1 && lastIndex === position;
11 }
12 });
13}
14
15if (!String.prototype.startsWith) {
16 Object.defineProperty(String.prototype, 'startsWith', {
17 enumerable: false,
18 configurable: false,
19 writable: false,
20 value: function (searchString, position) {
21 position = position || 0;
22 return this.indexOf(searchString, position) === position;
23 }
24 });
25}
26
27if (!String.prototype.contains ) {
28 String.prototype.contains = function() {
29 return this.indexOf(arguments) !== -1;
30 };
31}
\No newline at end of file