js/Map and js/Set not handled in js->clj?

this looks incomplete to me

js->clj significantly predates the introduction of Map and Set to JS. But that by itself, of course, doesn’t explain why it hasn’t been added.

I don’t know whether it’s been considered at all, but I can think of a couple of reasons to avoid adding support for Map and Set to the built-in js->clj function:

  • Both Map and Set preserve insertion order. The CLJS counterparts do not
  • Both Map and Set rely on key comparison algorithm that differs from CLJS, which can lead to loss of data after a conversion

Whether or not those are relevant to the code you write is unknown to CLJS, so it can’t make all the right decisions for everyone.

At the same time, the js->clj function is trivial in its implementation - you can easily write the same function and extend it in any way you want, with all the specifics in mind.

1 Like

The above is correct.

I’ll add to that that js->clj is meant to convert JS objects. It never converts any instances of classes by default. You can use the IEncodeClojure protocol to implement support for that, although I would caution against doing so given the above reasons.