Skip to content

Commit 57cb4e2

Browse files
committed
src
1 parent c8db033 commit 57cb4e2

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/applied_science/js_interop.cljc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
(ns applied-science.js-interop
2+
(:refer-clojure :exclude [defn get get-in fn let select-keys assoc!]))
3+
4+
(defmacro lit [x] x)
5+
6+
(defmacro defn [& body]
7+
`(clojure.core/defn ~@body))
8+
9+
(defmacro get-in [& body]
10+
`(clojure.core/get-in ~@body))
11+
12+
(defmacro fn [& body]
13+
`(clojure.core/fn ~@body))
14+
15+
(defmacro let [& body]
16+
`(clojure.core/let ~@body))
17+
18+
(defmacro call-in [obj path & fs]
19+
`(.. ~obj ~@(map #(symbol (str "-" %)) path) ~@(map list fs)))
20+
21+
(defmacro call [obj f & args]
22+
(list* (symbol (str "." (name f))) obj args))
23+
24+
(defmacro !set [obj k v]
25+
`(do (cljs.core/set! ~(list (symbol (str ".-" (name k))) obj) ~v)
26+
~obj))
27+
28+
(defmacro extend! [obj other]
29+
`(js/Object.assign ~obj ~other))
30+
31+
(defmacro push! [obj v]
32+
`(doto ~obj
33+
(.push ~v)))
34+
35+
(defmacro select-keys [obj ks]
36+
`(clojure.core/select-keys ~obj ~ks))
37+
38+
(defmacro assoc! [& body]
39+
`(clojure.core/assoc! ~@body))
40+
41+
(defmacro obj [& body]
42+
`(cljs.core/js-obj ~@body))
43+
44+
(defmacro get [& body]
45+
`(cljs.core/get ~@body))

0 commit comments

Comments
 (0)