Merge pull request #1575 from strongloop/fix/phantomjs

Polyfill Number.isFinite() to support PhantomJS
This commit is contained in:
Miroslav Bajtoš 2018-04-19 08:34:21 +02:00 committed by GitHub
commit c213352800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {