Liking cljdoc? Tell your friends :D

hara.data.base.diff


changedclj

(changed new old)

Outputs what has changed between the two maps

(changed {:a {:b {:c 3 :d 4}}} {:a {:b {:c 3}}}) => {:a {:b {:d 4}}}

Outputs what has changed between the two maps

(changed {:a {:b {:c 3 :d 4}}}
         {:a {:b {:c 3}}})
=> {:a {:b {:d 4}}}
raw docstring

diffclj

(diff m1 m2)
(diff m1 m2 reversible)

Finds the difference between two maps

(diff {:a 2} {:a 1}) => {:+ {} :- {} :> {[:a] 2}}

(diff {:a {:b 1 :d 3}} {:a {:c 2 :d 4}} true) => {:+ {[:a :b] 1} :- {[:a :c] 2} :> {[:a :d] 3} :< {[:a :d] 4}}

Finds the difference between two maps

(diff {:a 2} {:a 1})
=> {:+ {} :- {} :> {[:a] 2}}

(diff {:a {:b 1 :d 3}} {:a {:c 2 :d 4}} true)
=> {:+ {[:a :b] 1}
    :- {[:a :c] 2}
    :> {[:a :d] 3}
    :< {[:a :d] 4}}
raw docstring

diff-changesclj

(diff-changes m1 m2)
(diff-changes m1 m2 arr)

Finds changes in nested maps, does not consider new elements

(diff-changes {:a 2} {:a 1}) => {[:a] 2}

(diff-changes {:a {:b 1 :c 2}} {:a {:b 1 :c 3}}) => {[:a :c] 2}

Finds changes in nested maps, does not consider new elements

(diff-changes {:a 2} {:a 1})
=> {[:a] 2}

(diff-changes {:a {:b 1 :c 2}} {:a {:b 1 :c 3}})
=> {[:a :c] 2}

raw docstring

diff-newclj

(diff-new m1 m2)
(diff-new m1 m2 arr)

Finds new elements in nested maps, does not consider changes

(diff-new {:a 2} {:a 1}) => {}

(diff-new {:a {:b 1}} {:a {:c 2}}) => {[:a :b] 1}

Finds new elements in nested maps, does not consider changes

(diff-new {:a 2} {:a 1})
=> {}

(diff-new {:a {:b 1}} {:a {:c 2}})
=> {[:a :b] 1}

raw docstring

merge-or-replaceclj

(merge-or-replace x v)

If both are maps then merge, otherwis replace

(merge-or-replace {:a {:b {:c 2}}} {:a {:b {:c 3 :d 4}}}) => {:a {:b {:c 3 :d 4}}}

If both are maps then merge, otherwis replace

(merge-or-replace {:a {:b {:c 2}}} {:a {:b {:c 3 :d 4}}})
=> {:a {:b {:c 3 :d 4}}}
raw docstring

patchclj

(patch m diff)

Use the diff to convert one map to another in the forward direction based upon changes between the two.

(let [m1 {:a {:b 1 :d 3}} m2 {:a {:c 2 :d 4}} df (diff m2 m1)] (patch m1 df)) => {:a {:c 2 :d 4}}

Use the diff to convert one map to another in the forward
direction based upon changes between the two.

(let [m1  {:a {:b 1 :d 3}}
      m2  {:a {:c 2 :d 4}}
      df  (diff m2 m1)]
  (patch m1 df))
=> {:a {:c 2 :d 4}}
raw docstring

unpatchclj

(unpatch m diff)

Use the diff to convert one map to another in the reverse direction based upon changes between the two.

(let [m1 {:a {:b 1 :d 3}} m2 {:a {:c 2 :d 4}} df (diff m2 m1 true)] (unpatch m2 df)) => {:a {:b 1 :d 3}}

Use the diff to convert one map to another in the reverse
direction based upon changes between the two.

(let [m1  {:a {:b 1 :d 3}}
      m2  {:a {:c 2 :d 4}}
      df  (diff m2 m1 true)]
  (unpatch m2 df))
=> {:a {:b 1 :d 3}}
raw docstring

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

× close