You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.5 KiB
77 lines
1.5 KiB
// @noflow |
|
/** |
|
* React Flip Move - Polyfills |
|
* (c) 2016-present Joshua Comeau |
|
*/ |
|
|
|
/* eslint-disable */ |
|
|
|
if (!Array.prototype.find) { |
|
Array.prototype.find = function (predicate) { |
|
if (this === null) { |
|
throw new TypeError('Array.prototype.find called on null or undefined'); |
|
} |
|
if (typeof predicate !== 'function') { |
|
throw new TypeError('predicate must be a function'); |
|
} |
|
const list = Object(this); |
|
const length = list.length >>> 0; |
|
const thisArg = arguments[1]; |
|
let value; |
|
|
|
for (let i = 0; i < length; i++) { |
|
value = list[i]; |
|
if (predicate.call(thisArg, value, i, list)) { |
|
return value; |
|
} |
|
} |
|
return undefined; |
|
}; |
|
} |
|
|
|
if (!Array.prototype.every) { |
|
Array.prototype.every = function(callbackfn, thisArg) { |
|
'use strict'; |
|
var T, k; |
|
|
|
if (this == null) { |
|
throw new TypeError('this is null or not defined'); |
|
} |
|
|
|
var O = Object(this); |
|
var len = O.length >>> 0; |
|
|
|
if (typeof callbackfn !== 'function') { |
|
throw new TypeError(); |
|
} |
|
|
|
if (arguments.length > 1) { |
|
T = thisArg; |
|
} |
|
|
|
k = 0; |
|
|
|
while (k < len) { |
|
|
|
var kValue; |
|
|
|
if (k in O) { |
|
kValue = O[k]; |
|
|
|
var testResult = callbackfn.call(T, kValue, k, O); |
|
|
|
if (!testResult) { |
|
return false; |
|
} |
|
} |
|
k++; |
|
} |
|
return true; |
|
}; |
|
} |
|
|
|
if (!Array.isArray) { |
|
Array.isArray = function(arg) { |
|
return Object.prototype.toString.call(arg) === '[object Array]'; |
|
}; |
|
}
|
|
|