Add String.prototype.includes polyfill

Summary:
Add a polyfill for `String.prototype.includes` taken from MDN (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
See https://github.com/facebook/react-native/issues/5727
Closes https://github.com/facebook/react-native/pull/5735

Reviewed By: svcscm

Differential Revision: D2906667

Pulled By: vjeux

fb-gh-sync-id: e02f605bf57171062b29a98b98ba9fc898cedfc2
This commit is contained in:
Corentin Smith 2016-02-05 12:08:49 -08:00 коммит произвёл facebook-github-bot-7
Родитель d2ab6cabd4
Коммит 2f73ad0241
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -83,3 +83,18 @@ if (!String.prototype.repeat) {
return result;
};
}
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}