All Projects → mfikes → Cljs Bean

mfikes / Cljs Bean

Licence: epl-1.0
Efficient JavaScript object interop via idiomatic ClojureScript

Programming Languages

clojure
4091 projects

CLJS Bean

Like clojure.core/bean, but for ClojureScript.

Clojars Project cljdoc badge Build Status

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:

Overview

Object Extraction

Recursive Beans

Key Mapping

Transit

License

Copyright © 2019–2020 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].