Skip to content

Commit 3b552f8

Browse files
committed
add polyfill for String.includes
1 parent e2031b1 commit 3b552f8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export function initialize() {
2+
3+
// Source: https://developer.mozilla.org/cs/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
4+
if (!String.prototype.includes) {
5+
String.prototype.includes = function(search, start) {
6+
'use strict';
7+
if (typeof start !== 'number') {
8+
start = 0;
9+
}
10+
if (start + search.length > this.length) {
11+
return false;
12+
} else {
13+
return this.indexOf(search, start) !== -1;
14+
}
15+
};
16+
}
17+
}
18+
19+
export default {
20+
name: 'add-string-includes-polyfill',
21+
initialize
22+
};

0 commit comments

Comments
 (0)