Skip to content

Commit

Permalink
Support extend-type function IPrintWithWriter
Browse files Browse the repository at this point in the history
Let's users do

(extend-type function
  IPrintWithWriter
  (-pr-writer [obj writer _]
    (let [name (.-name obj)
          name (if (empty? name)
                 "Function"
                 name)]
      (write-all writer "#object[" name "]"))))
  • Loading branch information
mfikes committed Mar 2, 2016
1 parent f58dcdf commit 035c041
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9068,11 +9068,13 @@ reduces them without incurring seq initialization"
(-write writer obj))

^boolean (goog/isFunction obj)
(let [name (.-name obj)
name (if (or (nil? name) (gstring/isEmpty name))
"Function"
name)]
(write-all writer "#object[" name " \"" (str obj) "\"]"))
(if (satisfies? IPrintWithWriter obj)
(-pr-writer obj writer opts)
(let [name (.-name obj)
name (if (or (nil? name) (gstring/isEmpty name))
"Function"
name)]
(write-all writer "#object[" name " \"" (str obj) "\"]")))

(instance? js/Date obj)
(let [normalize (fn [n len]
Expand Down

0 comments on commit 035c041

Please sign in to comment.