(js->clj {:a 1} :keywordize-keys symbol)
{:a 1}
Making :keywordize-keys
accept a function there seems an improvement. Open to patch?context:
#?(:cljs
(do (def fs (let [m (js->clj (js/require "fs"))]
(zipmap (map symbol (keys m)) (vals m))))
(deftest add-object-as-namespace
(is (str/includes?
(tu/eval* "(str (fs/readFileSync \"README.md\"))" {:namespaces {'fs fs}})
"EPL")))))
then it wouldn’t be “keywordizing” though 🙃
“symbolizing” in your case
there is actually a ticket in CLJ for this
to break out the generic code here into a new more abstract function
or sorry I'm thinking of clojure.walk stuff
but same problem
@alexmiller for clojure.walk/keywordize-keys it's also a good idea
So do you not feel the name becomes wrong if you can configure it to arbitrary fn? I guess it could be just me being pedantic.
:keywordize-keys str
seems almost the opposite of what it was meant to do in a case like js->clj
I think more common is just key-fn
as the option
like as in cheshire
or I believe a few others
I was actually remembering that cheshire had the same name, but apparently it uses a positional parameter for it. So maybe a new option :key-fn
is less confusing
ah if it’s positional, perhaps I was thinking of some other lib
a new option is also less likely to break existing code. what if someone passed a function as a truthy value and didn't care what function it was
ah sneaky
overall though, it does seem it could be useful to have the key fn be pluggable. however, is this already covered by this lib? https://github.com/mfikes/cljs-bean perhaps it is not pluggable there either (haven’t looked)
it has :prop->key
and :key->prop
but I'm not sure if that's available in the js->clj
equivalent
seems it isn't
a lot of my open source coding experience is writing and rewriting various versions of js->clj
and clj->js
@roman01la some nice runtime perf patches, thanks!
@dnolen FWIW, I think we should fix https://clojure.atlassian.net/browse/CLJS-3205 before applying too many other patches (flying blind a little now) I may take a crack at if if I get a little time soon
Oh that’s just because of the build scripts using http urls?
Maybe... something funky is also going on with Travis. I'm hoping it is the same and a trivial fix
Ok I can audit the build scripts for any obvious things
Cool