Closed mfikes closed 2 years ago
Good idea
I think we should test that the protocol exists (defprotocol
generates a named JavaScript function) and only then extend. Then we can maintain compatibility with versions of ClojureScript without this protocol.
See also #18
Oneline to reproduce
clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"} com.cognitect/transit-cljs {:mvn/version "0.8.256"}}}' -m cljs.main -re node -e "(require '[cognitect.transit :as t]) (let [data (random-uuid) data' (t/read (t/reader :json) (t/write (t/writer :json) data))] (prn {:misc (mapv (juxt identity uuid? type) [data data']) :eq? (= data data')}))"
https://github.com/cognitect/transit-cljs/blob/master/README.md#contributing
Because transit is incorporated into products and client projects, we prefer to do development internally and are not accepting pull requests or patches.
Is it still true? Even if not merged, a pull request with implementation / testing would speed up the process?
@souenzzo thanks for the bump, will take a look at this tomorrow.
First, thanks for this library, it is a key piece of infrastructure that we use every single day; and if it didn't exist we would have to start by building it.
I encountered this:
dev:cljs.user=> x
#uuid "987126fe-7dbb-40b0-9bbe-004a4611f2dc"
dev:cljs.user=> (uuid? x)
false
dev:cljs.user=> (type x)
#object[Transit$UUID]
Thanks for your time and consideration.
(extend-type com.cognitect.transit.types/UUID IUUID)
does work but it would be great to get it fixed in the core. Thanks!
This looks like it hasn't been fixed yet. When reading UUIDs from transit returns something of type Transit/UUID
, and the predicate uuid?
returns false. What's worse is that they print the same and it took me a while to realise what's wrong.
Fixed in master.
There is code in transit-cljs that supports transparently treating core ClojureScript UUID types and the Transit-specific UUID type as being equivalent.
Recently,
cljs.core/uuid?
was added, but it returnsfalse
for Transit-specific UUIDs.Perhaps this could be fixed by doing something like
(extend-type ty/UUID IUUID)
in the Transit cljs core namespace.