Skip to content

Commit 6f70adc

Browse files
committed
Adds print tools for development
1 parent bccec8a commit 6f70adc

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject jtk-dvlp/core.async-helpers "3.1.0-SNAPSHOT"
1+
(defproject jtk-dvlp/core.async-helpers "3.2.0-SNAPSHOT"
22
:description
33
"Helper pack for core.async"
44

src/jtk_dvlp/async/print.cljc

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
(ns jtk-dvlp.async.print
2+
#?(:cljs
3+
(:require-macros
4+
[jtk-dvlp.async.print :refer [<debug <println <pprint]]))
5+
6+
#?(:clj
7+
(:require
8+
[jtk-dvlp.async]
9+
[clojure.pprint])
10+
11+
:cljs
12+
(:require
13+
[jtk-dvlp.async]
14+
[cljs.pprint])))
15+
16+
17+
#?(:clj
18+
(defmacro <debug
19+
[print-fn <form]
20+
`(jtk-dvlp.async/go
21+
(try
22+
(~print-fn (jtk-dvlp.async/<! ~<form))
23+
(catch :default e#
24+
(~print-fn e#))))))
25+
26+
#?(:clj
27+
(defmacro <println
28+
[<form]
29+
`(<debug println ~<form)))
30+
31+
#?(:clj
32+
(defmacro <pprint
33+
[<form]
34+
(let [pprint
35+
(if (:ns &env)
36+
'cljs.pprint/pprint
37+
'clojure.pprint/pprint)]
38+
39+
`(<debug ~pprint ~<form))))

0 commit comments

Comments
 (0)