Skip to content

Commit 61308c7

Browse files
author
dnolen
committed
compute read/write opts for transit if possible, handle JSValue
1 parent 8f1f977 commit 61308c7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@
5555

5656
(def ^:dynamic *file-defs* nil)
5757

58+
#?(:clj
59+
(def transit-read-opts
60+
(util/compile-if (import '[com.cognitect.transit ReadHandler])
61+
{:handlers
62+
{"cljs/js"
63+
(reify com.cognitect.transit.ReadHandler
64+
(fromRep [_ v] (JSValue. v)))}})))
65+
66+
#?(:clj
67+
(def transit-write-opts
68+
(util/compile-if (import '[com.cognitect.transit WriteHandler])
69+
{:handlers
70+
{JSValue
71+
(reify com.cognitect.transit.WriteHandler
72+
(tag [_ _] "cljs/js")
73+
(rep [_ js] (.val ^JSValue js))
74+
(stringRep [_ _] nil))}})))
75+
5876
#?(:clj
5977
(def transit
6078
(delay

0 commit comments

Comments
 (0)