spec-tools icon indicating copy to clipboard operation
spec-tools copied to clipboard

Coerce JS objects?

Open pepijndevos opened this issue 2 years ago • 2 comments

I was trying to coerce some data that came from JS land. After you do js-clj it works nicely, but of course this creates a bunch of extra intermediate values. For example a JS array first gets converted to a vector, and then again to a set.

Would it be possible to add a few transforms that coerce JS values directly?

pepijndevos avatar Aug 30 '21 14:08 pepijndevos

sure, PR welcome!

ikitommi avatar Aug 30 '21 15:08 ikitommi

Awesome. Any pointers on what this would entail? I found this code but I'm not really sure how it works and what I'd need to add to support JS objects. https://github.com/metosin/spec-tools/blob/d05e6e3c76c3c6ff847aa3f8e66344df2705aeae/src/spec_tools/transform.cljc#L207

pepijndevos avatar Aug 30 '21 17:08 pepijndevos