5
5
if ( String . prototype . repeat === undefined ) {
6
6
// tslint:disable-next-line:space-before-function-paren
7
7
String . prototype . repeat = function ( count ) : string {
8
- 'use strict' ;
9
8
if ( this === null ) {
10
9
throw new TypeError ( 'can\'t convert ' + this + ' to object' ) ;
11
10
}
@@ -51,7 +50,6 @@ if (String.prototype.startsWith === undefined) {
51
50
} ;
52
51
}
53
52
54
-
55
53
/**
56
54
* IE11 polyfill for string.endsWith function, from
57
55
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
@@ -66,6 +64,46 @@ if (String.prototype.endsWith === undefined) {
66
64
} ;
67
65
}
68
66
67
+ /**
68
+ * IE11 polyfill for string.includes function, from
69
+ * https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/includes
70
+ */
71
+ if ( String . prototype . includes === undefined ) {
72
+ // tslint:disable-next-line: space-before-function-paren
73
+ String . prototype . includes = function ( search , start ) : boolean {
74
+ if ( typeof start !== 'number' ) {
75
+ start = 0 ;
76
+ }
77
+
78
+ if ( start + search . length > this . length ) {
79
+ return false ;
80
+ } else {
81
+ return this . indexOf ( search , start ) !== - 1 ;
82
+ }
83
+ } ;
84
+ }
85
+
86
+ /**
87
+ * IE11 polyfill for string.trimLeft function, from
88
+ * https://stackoverflow.com/a/2308168
89
+ */
90
+ if ( String . prototype . trimLeft === undefined ) {
91
+ // tslint:disable-next-line: space-before-function-paren
92
+ String . prototype . trimLeft = function ( ) : string {
93
+ return this . replace ( / ^ \s + / , '' ) ;
94
+ } ;
95
+ }
96
+
97
+ /**
98
+ * IE11 polyfill for string.trimLeft function, from
99
+ * https://stackoverflow.com/a/2308168
100
+ */
101
+ if ( String . prototype . trimRight === undefined ) {
102
+ // tslint:disable-next-line: space-before-function-paren
103
+ String . prototype . trimRight = function ( ) : string {
104
+ return this . replace ( / ^ \s + / , '' ) ;
105
+ } ;
106
+ }
69
107
70
108
/**
71
109
* IE11 polyfill for Array.forEach function, from ...
0 commit comments