namespace
+ /
transform
placeholder-map
, when the value is not found on the map, the key is removed from result mapuuid?
m
following patterns defined at placeholder-map
.(transform {:a :a-name
:b "Fixed value"
:c-name [:c :name]} {:a-name "Aay" :c {:name "C"}})
; => {:a "Aay", :b "Fixed value", :c-name "C"}
(transform {:a {:name :a-name
:surname (fn [m k] "the Letter")}
:b 8} {:a-name "Aay"})
; => {:a {:name "Aay", :surname "the Letter"}, :b 8}
(transform {:a-first-name [:a :names 0] :a-last-name [:a :names last]}
{:a {:names ["Aaay" "the letter"]}})
; => {:a-first-name "Aaay", :a-last-name "the letter"}
(transform {:a-first-name :a :missing-prop :missing}
{:a "Aaay"})
; => {:a-first-name "Aaay", :missing-prop :missing}
(transform {:a-first-name :a :missing-prop (opt :missing)}
{:a "Aaay"})
; => {:a-first-name "Aaay"}
(transform-keys kebab-key->snake-str {:my-message "something" :payload {:my-name "Lenin"}})
; => {"my_message" "something", "payload" {"my_name" "Lenin"}}
(transform-keys (partial kebab-key->namespaced-key "test") {:id 1, :name "croissant", :unit-grams 200, :price 5.40M})
; => {:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}
(transform-keys-1-depth kebab-key->snake-str {:my-message "something" :payload {:my-name "Lenin"}})
; => {"my_message" "something", "payload" {:my-name "Lenin"}}
(transform-keys-1-depth (partial kebab-key->namespaced-key "test") {:id 1, :name "croissant", :unit-grams 200, :price 5.40M})
; => {:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}
(transform-values uuid->str {:name "something" :id #uuid "4a26cc9f-e854-4f93-b6c5-cda86c48544c"})
; => {:name "something" :id "4a26cc9f-e854-4f93-b6c5-cda86c48544c"}
(transform-values uuid->str [{:name "something" :id #uuid "4a26cc9f-e854-4f93-b6c5-cda86c48544c"}
{:name "smt else" :id #uuid "3a22cc9f-e854-4f93-b6c5-cda86c48544c"}])
; => [{:name "something" :id "4a26cc9f-e854-4f93-b6c5-cda86c48544c"}{:name "smt else" :id "3a22cc9f-e854-4f93-b6c5-cda86c48544c"}]
(transform-values-1-depth uuid->str {:name "something" :id #uuid "4a26cc9f-e854-4f93-b6c5-cda86c48544c"})
; => {:name "something" :id "4a26cc9f-e854-4f93-b6c5-cda86c48544c"}
(transform-values-1-depth uuid->str [{:name "something" :id #uuid "4a26cc9f-e854-4f93-b6c5-cda86c48544c"}
{:name "smt else" :id #uuid "3a22cc9f-e854-4f93-b6c5-cda86c48544c" :sub-entity {:id #uuid "3a22cc9f-e854-4f93-b6c5-cda86c48544c"}}])
; => [{:name "something" :id "4a26cc9f-e854-4f93-b6c5-cda86c48544c"}{:name "smt else" :id "3a22cc9f-e854-4f93-b6c5-cda86c48544c" :sub-entity {:id #uuid "3a22cc9f-e854-4f93-b6c5-cda86c48544c"}}]
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close