std.text.diff
->string
added in 3.0
(->string deltas)returns a human readable output of the diffs
(println (-> (diff “10\n11\n \n13\n14” “10\n18\n \n19\n14”) (->string)))
create-chunk
added in 3.0
(create-chunk {:keys [position lines]})creates a Chunk object from map
(create-chunk {:position 1 :lines “hello”}) => Chunk
create-delta
added in 3.0
(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
create-patch
added in 3.0
(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
diff
added in 3.0
(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”}}]
get-lines
added in 3.0
(get-lines deltas)creates a summary of the various diffs
(summary (diff “10\n11\n \n13\n14” “10\n18\n \n19\n14”)) => {:deletes 2, :inserts 2}
patch
added in 3.0
(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”
summary
added in 3.0
(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}
unpatch
added in 3.0
(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”