Merge pull request #1575 from strongloop/fix/phantomjs
Polyfill Number.isFinite() to support PhantomJS
This commit is contained in:
commit
c213352800
|
@ -451,6 +451,10 @@ function deepMergeProperty(base, extras) {
|
||||||
return mergedProperty;
|
return mergedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const numberIsFinite = Number.isFinite || function(value) {
|
||||||
|
return typeof value === 'number' && isFinite(value);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a property __rank to array elements of type object {}
|
* Adds a property __rank to array elements of type object {}
|
||||||
* If an inner element already has the __rank property it is not altered
|
* 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
|
* @return rankedArray The original array with newly ranked elements
|
||||||
*/
|
*/
|
||||||
function rankArrayElements(array, rank) {
|
function rankArrayElements(array, rank) {
|
||||||
if (!Array.isArray(array) || !Number.isFinite(rank))
|
if (!Array.isArray(array) || !numberIsFinite(rank))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
array.forEach(function(el) {
|
array.forEach(function(el) {
|
||||||
|
|
Loading…
Reference in New Issue