Fork me on GitHub
#specter
<
2016-11-01
>
joshkh16:11:55

i noticed that adding specter to my clojurescript project increased the compiled file size from 550kb to 830kb after google closure advanced optimization. that's quite an increase, and i'm only referencing [select ALL]. does that seem normal?

nathanmarz16:11:28

@joshkh I'm not familiar enough with cljs to understand those details

nathanmarz16:11:49

any idea what the increase is? the compiled js for specter?

joshkh16:11:17

i'll investigate. it's a bit hard to tell at first glance because advanced optimization munges everything into one garbled file.

joshkh16:11:39

i'll try the same with simple optimization and see where it gets me 🙂

nathanmarz16:11:53

might be a good idea to open an issue on this to track it

joshkh16:11:59

gotcha, will do

shooodooken16:11:19

Having some issues transforming map: I expected the output to be {:parent {:grandchild {}}}

(require '[com.rpl.specter.macros :as spm])
(require '[com.rpl.specter :as sp])

(spm/transform [:parent sp/ALL] #(get-in % [:child]) {:parent {:child {:grandchild {}}}})
=> {:parent {nil nil}}
Running this will get me close to the desired output:
(spm/transform [:parent sp/ALL] #(get-in % [:child]) {:parent [{:child {:grandchild {}}}]})
=> {:parent [{:grandchild {}}]}

shooodooken16:11:50

how can i achieve the desired result without changing the datastructure?

shooodooken17:11:59

reading the docs for ALL ({:doc "Navigate to every element of the collection. For maps navigates to a vector of [key value]."}) tells me I'll have to deconstruct & reconstruct data structure manually.

nathanmarz18:11:12

@shooodooken is this what you want?

(transform :parent :child  {:parent {:child {:grandchild {}}}})

shooodooken21:11:49

yes sir, thank you. (the real code was bit more tricky but dropping the ALL was ultimately what I needed)