Skip to content

Commit

Permalink
easier way to print via console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Nov 10, 2013
1 parent 5827c4c commit da2fa52
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/cljs/cljs/core.cljs
Expand Up @@ -30,6 +30,7 @@
[f] (set! *print-fn* f))

(def ^:dynamic *flush-on-newline* true)
(def ^:dynamic *print-newline* true)
(def ^:dynamic *print-readably* true)
(def ^:dynamic *print-meta* false)
(def ^:dynamic *print-dup* false)
Expand All @@ -40,6 +41,16 @@
:meta *print-meta*
:dup *print-dup*})

(declare into-array)

(defn enable-console-print!
"Set *print-fn* to console.log"
[]
(set! *print-newline* false)
(set! *print-fn*
(fn [& args]
(.apply js/console.log js/console (into-array args)))))

(def
^{:doc "bound in a repl thread to the most recent value printed"}
*1)
Expand Down Expand Up @@ -6761,7 +6772,8 @@ reduces them without incurring seq initialization"
"Same as print followed by (newline)"
[& objs]
(pr-with-opts objs (assoc (pr-opts) :readably false))
(newline (pr-opts)))
(when *print-newline*
(newline (pr-opts))))

(defn println-str
"println to a string, returning it"
Expand All @@ -6772,7 +6784,8 @@ reduces them without incurring seq initialization"
"Same as pr followed by (newline)."
[& objs]
(pr-with-opts objs (pr-opts))
(newline (pr-opts)))
(when *print-newline*
(newline (pr-opts))))

(extend-protocol IPrintWithWriter
LazySeq
Expand Down

0 comments on commit da2fa52

Please sign in to comment.