Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
[Fix #359] Workaround the transit-cljs map entry issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arichiardi committed Feb 20, 2018
1 parent 234284f commit 2b43018
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/cljs/snapshot/lumo/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@

(def ^:private ^:const JSON_EXT ".json")

(def read-opts
{"cljs/MapEntry" (transit/read-handler (fn [[k v]] (MapEntry. k v nil)))})

(defn transit-json->cljs
[json]
(let [rdr (transit/reader :json)]
(let [rdr (transit/reader :json read-opts)]
(transit/read rdr json)))

;; the read-opts and write-opts maps are necessary because of:
;; https://github.com/cognitect/transit-cljs/issues/33
(def write-opts
{cljs.core/MapEntry
(transit/write-handler
(fn [_] "cljs/MapEntry")
(fn [entry] [(-key entry) (-val entry)]))})

(defn cljs->transit-json
[x]
(let [wtr (transit/writer :json)]
(let [wtr (transit/writer :json write-opts)]
(transit/write wtr x)))

(defn- load-core-analysis-cache
Expand Down

0 comments on commit 2b43018

Please sign in to comment.