fipp
fipp copied to clipboard
Strategy to print `goog.math/Long`
goog.math/Long is not showing up very well
#?(:cljs
(let [x (goog.math/Long.fromString "123")]
(with-out-str (fipp/pprint {:test x} {:width 120}))))
It evaluates to the following
"{:test #object[#object[Long]]}\n"
Problem gets fixed by using the IEdn protocol
#?(:cljs
(extend-protocol IEdn
goog.math/Long
(-edn [x]
(js/Number (.toString ^goog.math/Long x)))))
Is using the IEdn protocol is the right approach for this problem. If yes then please consider documenting the IEdn protocol in the readme.
Yes, IEdn is the right way to do this. I should probably document it.
However, I think you may want to avoid losing precision by doing something like this:
#?(:cljs
(extend-protocol IEdn
goog.math/Long
(-edn [x]
(tagged-literal 'goog/long (.toString ^goog.math/Long x)))))
Closing in favor of https://github.com/brandonbloom/fipp/issues/91