Liking cljdoc? Tell your friends :D

editscript.core


combineclj/s

(combine this that)

Concate that editscript onto this editscript, return the new editscript

Concate that editscript onto this editscript, return the new
editscript
sourceraw docstring

diffclj/s

(diff a b)
(diff a b {:keys [algo str-diff?] :or {algo :a-star str-diff? false}})

Create an editscript to represent the transformations needed to turn a Clojure data structure a into another Clojure data structure b.

This function accepts any nested Clojure data structures. In Clojure, those implement IPersistentVector, IPersistentMap, IPersistentList, and IPersistentSet will be treated as collections. The same are true for the corresponding deftypes in Clojurescript, such as PersistentVector, PersistentMap, and so on. Anything else are treated as atomic values.

The editscript is represented as a vector of basic operations: add :+, delete :-, and replace :r. Each operation also include a path to the location of the operation, which is similar to the path vector in update-in. However, editscript path works for all above four collection types, not just associative ones. For :+ and :r, a new value is also required.

The following options are supported in the option map:

  • :algo chooses the diff algorithm. The value can be :a-star (default) or :quick; :a-star algorithm minimize the size of the resulting editscript, :quick algorithm is much faster, but does not producing diff with minimal size.

  • :str-diff? indicates a desire to perform string diff. It may reduce the result size for small changes in long strings, but will incur a slight computation cost. The value is a boolean: true or false (default). When enabled, the diff algorithm will perform string diff if the changes are less than 30 percent of the string length; otherwise, whole string replacement will be used.

Create an editscript to represent the transformations needed to turn a
Clojure data structure `a` into another Clojure data structure `b`.

This function accepts any nested Clojure data structures. In Clojure, those
implement `IPersistentVector`, `IPersistentMap`, `IPersistentList`,
and `IPersistentSet` will be treated as collections. The same are true for
the corresponding deftypes in Clojurescript, such as `PersistentVector`,
`PersistentMap`, and so on. Anything else are treated as atomic values.

The editscript is represented as a vector of basic operations: add `:+`,
delete `:-`, and replace `:r`. Each operation also include a path to the
location of the operation, which is similar to the path vector in `update-in`.
However, editscript path works for all above four collection types, not just
associative ones. For `:+` and `:r`, a new value is also required.


The following options are supported in the option map:

* `:algo`  chooses the diff algorithm. The value can be `:a-star` (default) or
`:quick`; `:a-star` algorithm minimize the size of the resulting editscript,
`:quick` algorithm is much faster, but does not producing diff with minimal size.

* `:str-diff?` indicates a desire to perform string diff. It  may reduce the
result size for small changes in long strings, but will incur a slight computation
cost. The value is a boolean: `true` or `false` (default). When enabled, the diff
algorithm will perform string diff if the changes are less than 30 percent of the
string length; otherwise, whole string replacement will be used.
sourceraw docstring

edit-distanceclj/s

(edit-distance es)

Report the edit distance of the editscript, i.e. number of operations

Report the edit distance of the editscript, i.e. number of
operations
sourceraw docstring

edits->scriptclj/s

(edits->script edits)

Create an EditScript instance from a vector of edits, like those obtained through calling get-edits on an EditScript

Create an EditScript instance from a vector of edits, like those
obtained through calling `get-edits` on an EditScript
sourceraw docstring

get-adds-numclj/s

(get-adds-num es)

Report the number of additions in the editscript

Report the number of additions in the editscript
sourceraw docstring

get-dels-numclj/s

(get-dels-num es)

Report the number of deletes in the editscript

Report the number of deletes in the editscript
sourceraw docstring

get-editsclj/s

(get-edits es)

Report the edits of the editscript as a vector

Report the edits of the editscript as a vector
sourceraw docstring

get-reps-numclj/s

(get-reps-num es)

Report the edits of replacements in the editscript

Report the edits of replacements in the editscript
sourceraw docstring

get-sizeclj/s

(get-size es)

Report the size of the editscript

Report the size of the editscript
sourceraw docstring

patchclj/s

(patch a script)

Apply the editscript script on a to produce b, assuming the script is the results of running (diff a b), such that (= b (patch a (diff a b))) is true

Apply the editscript `script` on `a` to produce `b`, assuming the
script is the results of running  `(diff a b)`, such that
`(= b (patch a (diff a b)))` is true
sourceraw docstring

valid-edits?clj/s

(valid-edits? edits)

Check if the given vector represents valid edits that can be turned into an EditScript

Check if the given vector represents valid edits that can be turned
into an EditScript
sourceraw docstring

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

× close