Liking cljdoc? Tell your friends :D

hara.data.base.nested


clean-nestedclj

(clean-nested m)

Returns a associative with nils and empty hash-maps removed.

(clean-nested {:a {:b {:c {}}}}) => {}

(clean-nested {:a {:b {:c {} :d 1 :e nil}}}) => {:a {:b {:d 1}}}

Returns a associative with nils and empty hash-maps removed.

(clean-nested {:a {:b {:c {}}}})
=> {}

(clean-nested {:a {:b {:c {} :d 1 :e nil}}})
=> {:a {:b {:d 1}}}
raw docstring

dissoc-nestedclj

(dissoc-nested m ks)

Returns m without all nested keys in ks.

(dissoc-nested {:a {:b 1 :c {:b 1}}} [:b]) => {:a {:c {}}}

Returns `m` without all nested keys in `ks`.

(dissoc-nested {:a {:b 1 :c {:b 1}}} [:b])
=> {:a {:c {}}}
raw docstring

key-pathsclj

(key-paths m)
(key-paths m max)
(key-paths m max arr)

The set of all paths in a map, governed by a max level of nesting

(key-paths {:a {:b 1} :c {:d 1}}) => (contains [[:c :d] [:a :b]] :in-any-order)

(key-paths {:a {:b 1} :c {:d 1}} 1) => (contains [[:c] [:a]] :in-any-order)

The set of all paths in a map, governed by a max level of nesting

(key-paths {:a {:b 1} :c {:d 1}})
=> (contains [[:c :d] [:a :b]] :in-any-order)

(key-paths {:a {:b 1} :c {:d 1}} 1)
=> (contains [[:c] [:a]] :in-any-order)
raw docstring

keys-nestedclj

(keys-nested m)

The set of all nested keys in a map

(keys-nested {:a {:b 1 :c {:d 1}}}) => #{:a :b :c :d}

The set of all nested keys in a map

(keys-nested {:a {:b 1 :c {:d 1}}})
=> #{:a :b :c :d}
raw docstring

merge-nestedclj

(merge-nested)
(merge-nested m)
(merge-nested m1 m2)
(merge-nested m1 m2 & ms)

Merges nested values from left to right.

(merge-nested {:a {:b {:c 3}}} {:a {:b 3}}) => {:a {:b 3}}

(merge-nested {:a {:b {:c 1 :d 2}}} {:a {:b {:c 3}}}) => {:a {:b {:c 3 :d 2}}}

Merges nested values from left to right.

(merge-nested {:a {:b {:c 3}}} {:a {:b 3}})
=> {:a {:b 3}}

(merge-nested {:a {:b {:c 1 :d 2}}}
              {:a {:b {:c 3}}})
=> {:a {:b {:c 3 :d 2}}}
raw docstring

merge-new-nestedclj

(merge-new-nested)
(merge-new-nested m)
(merge-new-nested m1 m2)
(merge-new-nested m1 m2 & more)

Merges nested values from left to right, provided the merged value does not exist

(merge-new-nested {:a {:b 2}} {:a {:c 2}}) => {:a {:b 2 :c 2}}

(merge-new-nested {:b {:c :old}} {:b {:c :new}}) => {:b {:c :old}}

Merges nested values from left to right, provided the merged value does not exist

(merge-new-nested {:a {:b 2}} {:a {:c 2}})
=> {:a {:b 2 :c 2}}

(merge-new-nested {:b {:c :old}} {:b {:c :new}})
=> {:b {:c :old}}
raw docstring

unique-nestedclj

(unique-nested m1 m2)

All nested values in m1 that are unique to those in m2.

(unique-nested {:a {:b 1}} {:a {:b 1 :c 1}}) => {}

(unique-nested {:a {:b 1 :c 1}} {:a {:b 1}}) => {:a {:c 1}}

All nested values in `m1` that are unique to those in `m2`.

(unique-nested {:a {:b 1}}
               {:a {:b 1 :c 1}})
=> {}

(unique-nested {:a {:b 1 :c 1}}
               {:a {:b 1}})
=> {:a {:c 1}}
raw docstring

update-keys-inclj

(update-keys-in m arr f & args)

updates all keys in a map with given function

(update-keys-in {:x {["a" "b"] 1 ["c" "d"] 2}} [:x] string/joinl) => {:x {"ab" 1 "cd" 2}}

(update-keys-in {:a {:c 1} :b {:d 2}} 2 name) => {:b {"d" 2}, :a {"c" 1}}

updates all keys in a map with given function

(update-keys-in {:x {["a" "b"] 1 ["c" "d"] 2}} [:x] string/joinl)
=> {:x {"ab" 1 "cd" 2}}

(update-keys-in {:a {:c 1} :b {:d 2}} 2 name)
=> {:b {"d" 2}, :a {"c" 1}}
raw docstring

update-vals-inclj

(update-vals-in m arr f & args)

updates all values in a map with given function

(update-vals-in {:a 1 :b 2} [] inc) => {:a 2 :b 3}

(update-vals-in {:a {:c 1} :b 2} [:a] inc) => {:a {:c 2} :b 2}

(update-vals-in {:a {:c 1} :b {:d 2}} 2 inc) => {:a {:c 2} :b {:d 3}}

(update-vals-in {:a 1 :b 2} 1 inc) => {:a 2, :b 3}

updates all values in a map with given function

(update-vals-in {:a 1 :b 2} [] inc)
=> {:a 2 :b 3}

(update-vals-in {:a {:c 1} :b 2} [:a] inc)
=> {:a {:c 2} :b 2}

(update-vals-in {:a {:c 1} :b {:d 2}} 2 inc)
=> {:a {:c 2} :b {:d 3}}

(update-vals-in {:a 1 :b 2} 1 inc)
=> {:a 2, :b 3}
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close