refactor(common): refactor polyfill of String.prototype.includes

This commit is contained in:
Pig Fang 2017-12-27 17:47:13 +08:00
parent f4c21a0cb2
commit b1fa8c098b

View File

@ -2,17 +2,9 @@
// polyfill of String.prototype.includes
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;
}
String.prototype.includes = function(search) {
// Copied from core-js
return !!~this.indexOf(search, arguments.length > 1 ? arguments[1] : undefined);
};
}