From 156bbb91e39dfcbf06795e4e311ea214425cab2e Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 4 Mar 2021 16:02:31 -0600 Subject: [PATCH] Make limiting work in ClojureScript Change `keep-number-reasonable` so that it doesn't use Java's Double class when running in ClojureScript. I believe this should work, but I haven't tested it with ClojureScript yet. --- src/propeller/push/utils/helpers.cljc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/propeller/push/utils/helpers.cljc b/src/propeller/push/utils/helpers.cljc index 1596827..748f9eb 100755 --- a/src/propeller/push/utils/helpers.cljc +++ b/src/propeller/push/utils/helpers.cljc @@ -17,10 +17,13 @@ :else n) :else (cond - (Double/isNaN n) 0.0 - (or (= n Double/POSITIVE_INFINITY) + (#?(:clj Double/isNaN + :cljs js/isNaN) n) 0.0 + (or (= n #?(:clj Double/POSITIVE_INFINITY + :cljs js/Infinity)) (> n globals/max-number-magnitude)) globals/max-number-magnitude - (or (= n Double/NEGATIVE_INFINITY) + (or (= n #?(:clj Double/NEGATIVE_INFINITY + :cljs js/-Infinity)) (< n (- globals/max-number-magnitude))) (- globals/max-number-magnitude) (< (- globals/min-number-magnitude) n globals/min-number-magnitude) 0.0 :else n)))