Like clojure.core/bean, but for ClojureScript.
A bean function and ->clj and ->js converters enable working with JavaScript objects via thin wrappers implementing ClojureScript collection abstractions:
(require '[cljs-bean.core :refer [bean ->clj ->js]])
(bean #js {:a 1, :b 2})
;; {:a 1, :b 2}The converters enable idiomatic interop while being much faster than
equivalent constructs using js->clj and clj->js:
(let [{:keys [a b]} (->clj #js {:a 1, :b 2})]
(+ a b))
;; => 3
(into (->clj #js [1 2]) [3 4 5])
;; [1 2 3 4 5]
(->js *1)
;; #js [1 2 3 4 5]Read more:
Copyright © 2019–2022 Mike Fikes
Distributed under the EPL License, same as Clojure. See LICENSE.
The namespace cljs-bean.from.cljs.core contains source from ClojureScript which is licensed under the EPL license.