Skip to content

Commit

Permalink
Merge pull request #1575 from strongloop/fix/phantomjs
Browse files Browse the repository at this point in the history
Polyfill Number.isFinite() to support PhantomJS
  • Loading branch information
bajtos authored Apr 19, 2018
2 parents 2ac5efa + f847925 commit c213352
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit c213352

Please sign in to comment.