First install clojure
so the clj
command will be available.
brew install clojure
Clone and move core.cljs
to the right directory:
git clone https://gist.github.com/a6427534ea76cd4e9222a76eb398b289.git inc
cd inc
mkdir -p src/inc
mv core.cljs src/inc
To develop:
clj -m cljs.main --repl-env node
cljs.user=> (require '[inc.core])
cljs.user=> (inc.core/handle-input "1")
2
nil
;; change something in src/inc/core.cljs
cljs.user=> (require '[inc.core] :reload)
;; try the change
To compile the final output:
clj -m cljs.main --target node --output-to inc.js -O simple -c inc.core
chmod +x inc.js
Let's try!
$ time echo 1 | ./inc.js
2
echo 1 0.00s user 0.00s system 38% cpu 0.002 total
./inc.js 0.13s user 0.03s system 94% cpu 0.173 total
$ time ./inc.js 1
2
./inc.js 1 0.13s user 0.03s system 96% cpu 0.168 total
$ ./inc.js hello
Not a number: hello
$ echo $?
1
Yay.