This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-26
Channels
- # babashka (16)
- # beginners (38)
- # calva (11)
- # cider (35)
- # clj-kondo (3)
- # clj-otel (3)
- # clojure (28)
- # clojure-europe (11)
- # clojure-gamedev (14)
- # clojure-norway (42)
- # clojure-spec (4)
- # datalevin (10)
- # datomic (2)
- # emacs (8)
- # events (2)
- # fulcro (3)
- # gratitude (5)
- # hyperfiddle (3)
- # kaocha (1)
- # nbb (14)
- # nrepl (12)
- # portal (1)
- # re-frame (5)
- # releases (1)
- # shadow-cljs (36)
- # squint (167)
Using nbb to explore an API. I'm getting response data, converting it from json to edn via js->clj, and pprint'ing it. However, unlike js/console.log
the output is all in one line in the repl. Guessing in some part due to my editor of choice, but is there a way to get the formatted output to show in the nrepl server process like js/console.log
?
perhaps you can try (set! *print-fn* js/console.log)
or so?
Ooh will try
doesn't seem to work
Same
user=> (alter-var-root #'prn (constantly js/console.log))
#object[log]
user=> (prn 1)
1
nil
user=> (prn #js [1 2 3]))
[ 1, 2, 3 ]
nil
Oh... wait I was using clj->js
instead of js->clj
😵
oh :)
It would still be helpful if println, prn, pprint, etc... could output to the main nrepl server proc like js/console.log does but this is a big improvement at least 😅
Ooh actually, I can write a userland function for that. Would just call with-out-str to pprint my data, then console.log the str output
Thinking it would be nice for keeping particular data visible on my terminal that doesn't update frequently
Is it possible to invoke nbb scripts from a parent directory and possibly tools like Shadow CLJS without having to run shell commands? I am investigating using nbb to unify some build tasks in a pure CLJS project, and I would like to avoid makefiles and shell scripts if I can.
Sure, you can use load-file
in nbb and also you can use the Node libraries for spawning programs