Liking cljdoc? Tell your friends :D
All platforms.

diffuse.core


applyclj/s

(apply diff data)

Applies the change specified in the diff to data.

When the :type of diff is:

  • :missing, diff has the following format:
    {:type :missing}
    

    It represents a top level value which does not exist.

  • :value, diff has the following format:
    {:type :value
     :value val}
    

    It represents a new top level value which replaces any previous data.

  • :set, diff has the following format:
    {:type :set
     :disj #{val0 ...}
     :conj #{val1 ...}}
    

    :disj is applied first, then :conj No overlap is expected between the values in :disj and :conj.

  • :map, diff has the following format:
    {:type :map
     :key-op {key0 [:assoc val0]}
              key1 [:update diff1]
              key2 [:dissoc]
              ...}
    
  • :vector or a sequence, diff has the following format:
    {:type :vector
     :index-op {[:no-op size0]
                [:update [diff0 diff1 ...]]
                [:remove size2]
                [:insert [val0 val1 ...]]
                ...}}
    

    Consecutive elements in :index-op are not supposed to be of the same type.

When diff is nil, the data is returned unchanged.

Applies the change specified in the diff to data.

When the `:type` of diff is:
- `:missing`, diff has the following format:
  ```
  {:type :missing}
  ```
  It represents a top level value which does not exist.
- `:value`, diff has the following format:
  ```
  {:type :value
   :value val}
  ```
  It represents a new top level value which replaces any previous data.
- `:set`, diff has the following format:
  ```
  {:type :set
   :disj #{val0 ...}
   :conj #{val1 ...}}
  ```
  :disj is applied first, then :conj
  No overlap is expected between the values in :disj and :conj.
- `:map`, diff has the following format:
  ```
  {:type :map
   :key-op {key0 [:assoc val0]}
            key1 [:update diff1]
            key2 [:dissoc]
            ...}
  ```
- `:vector` or a sequence, diff has the following format:
  ```
  {:type :vector
   :index-op {[:no-op size0]
              [:update [diff0 diff1 ...]]
              [:remove size2]
              [:insert [val0 val1 ...]]
              ...}}
  ```
  Consecutive elements in :index-op are not supposed to be of the same type.

When diff is nil, the data is returned unchanged.
sourceraw docstring

compclj/s

(comp)
(comp diff)
(comp new-diff base-diff)
(comp diff-z diff-y & diffs)

Returns a diff whose application is equivalent to the consecutive application of multiple diffs.

We suppose that the diff were crafted without necessarily been aware of the data on which it would be applied. As a result, diffs are expected not to always have an effect on the data.

Therefore:

 (= (d/comp {:type :set, :disj #{:a}}
            {:type :set, :conj #{:a}})
    {:type :set, :disj #{:a}})
Returns a diff whose application is equivalent to the consecutive application of multiple diffs.

We suppose that the diff were crafted without necessarily been aware of the data on which it
would be applied. As a result, diffs are expected not to always have an effect on the data.

Therefore:
```
 (= (d/comp {:type :set, :disj #{:a}}
            {:type :set, :conj #{:a}})
    {:type :set, :disj #{:a}})
```
sourceraw docstring

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

× close