-
-
Save jhickner/1199718 to your computer and use it in GitHub Desktop.
Clojure sequentials & maps into JavaScript arrays and objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ->js [o] | |
(cond | |
(keyword? o) (name o) | |
(map? o) (let [out (js-obj)] | |
(doseq [[k v] o] | |
(aset out (->js k) (->js v))) | |
out) | |
(coll? o) (apply array (map ->js o)) | |
:else o)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working on making this recursive...