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.
This commit is contained in:
Erik Rauer 2021-03-04 16:02:31 -06:00
parent 7f5168769d
commit 156bbb91e3

View File

@ -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)))