From f8479253fab7311fcc8fcc3769f2384a8e175a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 17 Apr 2018 09:49:28 +0200 Subject: [PATCH] Polyfill Number.isFinite() to support PhantomJS --- lib/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index ac785b14b..3b99e637a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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) {