Polyfill Number.isFinite() to support PhantomJS

This commit is contained in:
Miroslav Bajtoš 2018-04-17 09:49:28 +02:00
parent 2ac5efa04a
commit f8479253fa
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
1 changed files with 5 additions and 1 deletions

View File

@ -451,6 +451,10 @@ function deepMergeProperty(base, extras) {
return mergedProperty;
}
const numberIsFinite = Number.isFinite || function(value) {
return typeof value === 'number' && isFinite(value);
};
/**
* Adds a property __rank to array elements of type object {}
* If an inner element already has the __rank property it is not altered
@ -461,7 +465,7 @@ function deepMergeProperty(base, extras) {
* @return rankedArray The original array with newly ranked elements
*/
function rankArrayElements(array, rank) {
if (!Array.isArray(array) || !Number.isFinite(rank))
if (!Array.isArray(array) || !numberIsFinite(rank))
return array;
array.forEach(function(el) {