Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 718 Bytes

recursive.md

File metadata and controls

22 lines (16 loc) · 718 Bytes

Recursive Beans

By default, the bean function behaves like Clojure’s in that it is not recursive:

(bean #js {:a 1, :obj #js {:x 13, :y 17} :vec #js [1 2 3]})
;; => {:a 1, :obj #js {:x 13, :y 17} :vec #js [1 2 3]}

Beans can be made to behave more like js->clj by supplying :recursive true:

(bean #js {:a 1, :obj #js {:x 13, :y 17} :vec #js [1 2 3]} :recursive true)
;; => {:a 1, :obj {:x 13, :y 17} :vec [1 2 3]}

The ->clj converter, when applied to JavaScript objects, automatically supplies :recursive true, so the above can be simplified to

(->clj #js {:a 1, :obj #js {:x 13, :y 17} :vec #js [1 2 3]})
;; => {:a 1, :obj {:x 13, :y 17} :vec [1 2 3]}