Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add cljx rules for inconsistencies
We do something different when the multimethods dispatch on object
type. Because Javascript doesn't have classes, we dispatch using a
keyword instead.
  • Loading branch information
rymndhng committed Feb 4, 2015
commit fb9a4ee0f576effbb2a096fd11b320177a206a69
9 changes: 6 additions & 3 deletions src/cljx/clj_diff/core.cljx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns clj-diff.core
"Diff, patch and related functions for Clojure sequences."
(:require [clj-diff [miller :as miller]]))
(:require [clj-diff.miller :as miller]))

(defn diff
"Create the edit script for transforming sequance a into sequence b.
Expand Down Expand Up @@ -49,13 +49,16 @@
patch will use the edit script to transform a into b.

(diff a b) -> x, (patch a x) -> b."
(fn [s _] (class s)))
#+clj
(fn [s _] (class s))
#+cljs
(fn [s _] (when (string? s) :string)))

(defmethod patch :default
[s edit-script]
(patch* s edit-script))

(defmethod patch String
(defmethod patch #+clj String #+cljs :string
[s edit-script]
(apply str (patch* s edit-script)))

Expand Down