cljs-bean
cljs-bean copied to clipboard
How to use bean and ->clj on objects like js/Error?
For now, for the following code:
(def e (js/Error. "test string"))
;; 1
(bean/e)
;; 2
(->clj/e)
- gives
{:clojure$core$protocols$Datafiable$ #js {}, :clojure$core$protocols$Datafiable$datafy$arity$1 #object[Function]
- gives
#object[Error Error: test string]
Would be better if it can give things like
{"message":foo, "line":foo, "column":foo, "stack":foo}
Relevant: https://clojure.atlassian.net/browse/CLJS-3014
Not sure on the details. Isn't it possible to use all the possible keys from an object to form a bean? So it will work not only in the specific case of Error->map ?
@introom One issue here is that js-keys
returns an empty array when applied to a js/Error
object.