macro | since v0.0-1443 | clojure.core/memfn | Edit |
(memfn name & args)
Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a JavaScript method as a first-class fn.
(core/defmacro memfn
[name & args]
(core/let [t (with-meta (gensym "target")
(meta name))]
`(fn [~t ~@args]
(. ~t (~name ~@args)))))