diff --git a/src/lambdaisland/deep_diff2/diff_impl.cljc b/src/lambdaisland/deep_diff2/diff_impl.cljc index 6b61af9..e864f87 100644 --- a/src/lambdaisland/deep_diff2/diff_impl.cljc +++ b/src/lambdaisland/deep_diff2/diff_impl.cljc @@ -97,17 +97,6 @@ (diff-seq-insertions ins) (into [])))) -(defn diff-string [exp act] - (->> (diff-seq exp act) - (map #(if (char? %) {:= %} %)) - (partition-by (comp first keys)) - (map (fn [[first-element :as coll]] - (let [head (first (keys first-element)) - contents (mapcat vals coll)] - {head (apply str contents) }) - ))) - ) - (defn diff-set [exp act] (into (into #{} @@ -142,7 +131,7 @@ exp-ks)))) (defn primitive? [x] - (or (number? x) (boolean? x) (inst? x) (keyword? x) (symbol? x))) + (or (number? x) (string? x) (boolean? x) (inst? x) (keyword? x) (symbol? x))) (defn diff-atom [exp act] (if (= exp act) @@ -162,30 +151,23 @@ (defn array? [x] (and x (.isArray (class x))))) -(defn diff - ([exp act] - (diff exp act {})) - ([exp act {:keys [diff-strings?] :as _opts}] - (cond - (nil? exp) - (diff-atom exp act) - - (and (diffable? exp) - (= (data/equality-partition exp) (data/equality-partition act))) - (diff-similar exp act) +(defn diff [exp act] + (cond + (nil? exp) + (diff-atom exp act) - (array? exp) - (diff-seq exp act) + (and (diffable? exp) + (= (data/equality-partition exp) (data/equality-partition act))) + (diff-similar exp act) - (record? exp) - (diff-map exp act) + (array? exp) + (diff-seq exp act) - (and diff-strings? - (string? exp)) - (diff-string exp act) + (record? exp) + (diff-map exp act) - :else - (diff-atom exp act)))) + :else + (diff-atom exp act))) (extend-protocol Diff #?(:clj java.util.Set :cljs cljs.core/PersistentHashSet)