Liking cljdoc? Tell your friends :D

hara.lib.diff


->stringclj

(->string deltas)

returns a human readable output of the diffs

(println (-> (diff "10\n11\n \n13\n14" "10\n18\n \n19\n14") (->string)))

returns a human readable output of the diffs
 
   (println (-> (diff "10\n11\n
\n13\n14"
                      "10\n18\n
\n19\n14")
               (->string)))
raw docstring

create-chunkclj

(create-chunk {:keys [position lines]})

creates a Chunk object from map

(create-chunk {:position 1 :lines ["hello"]}) => Chunk

creates a Chunk object from map

(create-chunk {:position 1
               :lines ["hello"]})
=> Chunk
raw docstring

create-deltaclj

(create-delta {:keys [type original revised]})

creates a Delta object from map

(create-delta {:type "CHANGE" :original {:position 1 :lines ["hello"]} :revised {:position 1 :lines []}}) => Delta

creates a Delta object from map

(create-delta {:type "CHANGE"
               :original {:position 1
                          :lines ["hello"]}
               :revised {:position 1
                         :lines []}})
=> Delta
raw docstring

create-patchclj

(create-patch arr)

creates a Patch object

(create-patch [{:type "CHANGE" :original {:position 1 :lines ["hello"]} :revised {:position 1 :lines ["world"]}} {:type "DELETE" :original {:position 1 :lines ["again"]} :revised {:position 1 :lines []}} {:type "INSERT" :original {:position 1 :lines []} :revised {:position 1 :lines ["again"]}}]) => Patch

creates a Patch object

(create-patch [{:type "CHANGE"
               :original {:position 1
                          :lines ["hello"]}
               :revised {:position 1
                         :lines ["world"]}}
               {:type "DELETE"
               :original {:position 1
                          :lines ["again"]}
              :revised {:position 1
                         :lines []}}
               {:type "INSERT"
                :original {:position 1
                           :lines []}
                :revised {:position 1
                          :lines ["again"]}}])
=> Patch
raw docstring

diffclj

(diff original revised)

returns a set of diff results

(diff "10\n11\n \n13\n14" "10\n18\n \n19\n14") => [{:type "CHANGE", :original {:count 1, :position 1, :lines ["11"]}, :revised {:count 1, :position 1, :lines ["18"]}} {:type "CHANGE", :original {:count 1, :position 4, :lines ["13"]}, :revised {:count 1, :position 4, :lines ["19"]}}]

returns a set of diff results
 
   (diff "10\n11\n
\n13\n14"
         "10\n18\n
\n19\n14")
   => [{:type "CHANGE",
        :original {:count 1,
                   :position 1,
                   :lines ["11"]},
        :revised {:count 1,
                  :position 1,
                 :lines ["18"]}}
       {:type "CHANGE",
        :original {:count 1,
                   :position 4,
                   :lines ["13"]},
        :revised {:count 1,
                  :position 4,
                  :lines ["19"]}}]
raw docstring

patchclj

(patch original diff)

takes a series of deltas and returns the revised result

(patch "10\n11\n \n13\n14" [{:type "CHANGE", :original {:count 1, :position 1, :lines ["11"]}, :revised {:count 1, :position 1, :lines ["18"]}} {:type "CHANGE", :original {:count 1, :position 4, :lines ["13"]}, :revised {:count 1, :position 4, :lines ["19"]}}]) => "10\n18\n\n\n19\n14"

takes a series of deltas and returns the revised result
 
   (patch "10\n11\n
\n13\n14"
          [{:type "CHANGE",
            :original {:count 1,
                       :position 1,
                       :lines ["11"]},
            :revised {:count 1,
                      :position 1,
                      :lines ["18"]}}
          {:type "CHANGE",
            :original {:count 1,
                       :position 4,
                       :lines ["13"]},
            :revised {:count 1,
                      :position 4,
                      :lines ["19"]}}])
   => "10\n18\n\n\n19\n14"
raw docstring

summaryclj

(summary deltas)

creates a summary of the various diffs

(summary (diff "10\n11\n \n13\n14" "10\n18\n \n19\n14")) => {:deletes 2, :inserts 2}

creates a summary of the various diffs
 
   (summary (diff "10\n11\n
\n13\n14"
                  "10\n18\n
\n19\n14"))
   => {:deletes 2, :inserts 2}
raw docstring

unpatchclj

(unpatch revised diff)

takes a series of deltas and restores the original result

(unpatch "10\n18\n\n\n19\n14" [{:type "CHANGE", :original {:count 1, :position 1, :lines ["11"]}, :revised {:count 1, :position 1, :lines ["18"]}} {:type "CHANGE", :original {:count 1, :position 4, :lines ["13"]}, :revised {:count 1, :position 4, :lines ["19"]}}]) => "10\n11\n \n13\n14"

takes a series of deltas and restores the original result
 
   (unpatch "10\n18\n\n\n19\n14"
            [{:type "CHANGE",
              :original {:count 1,
                         :position 1,
                         :lines ["11"]},
              :revised {:count 1,
                        :position 1,
                        :lines ["18"]}}
            {:type "CHANGE",
              :original {:count 1,
                         :position 4,
                         :lines ["13"]},
              :revised {:count 1,
                        :position 4,
                        :lines ["19"]}}])
   => "10\n11\n
\n13\n14"
raw docstring

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

× close