Hi!
I have an issue when trying to convert a javascript Array to a clojurescript
vector. When using js->clj it returns the same JS object without converting it.
Code:
(def paths (.readdirSync fs "resources/photos"))
;=> #<.DS_Store,2013,Aachen,Alicante,India Maria,Londres 2009>
(isa? paths js/Array)
;=> false
(type paths)
;=> #<function Array() { [native code] }>
(print (js->clj paths))
;=> #<.DS_Store,2013,Aachen,Alicante,India Maria,Londres 2009>nil
;; Same thing as before
(map #(str "whatever") paths)
;=> "Error evaluating:" (map (fn* [] (str "asdf")) paths) :as
"cljs.core.map.call(null,(function (){return
[cljs.core.str(\"asdf\")].join('');\n}),galeria.files.paths)"
Error: .DS_Store,2013,Aachen,Alicante,India Maria,Londres 2009is not ISeqable
at seq (cljs/core.cljs:39:9)
at cljs.core.map.map__2 (cljs/core.cljs:11:120)
at cljs.core.LazySeq.sval (cljs/core.cljs:43:23)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (cljs/core.cljs:55:30
....
I do not understand why it says it is not an Array but the type clearly shows
that the constructur is the Array js type.
I'm fairly new to the language and to clojurescript and I come from js so sorry
if I made some stupid mistake.
After a while I've found a JS workaround to make it work (concat the results to
an empty JS array):
(println (js->clj (.concat #js[] (.readdirSync fs "resources/photos"))))
;=> [.DS_Store 2013 Aachen Alicante India Maria Londres 2009]
Any help/advice would be greatly appreciated.
Thanks!
Joaquin
ps: Project conf
:dependencies [[org.clojure/clojure "1.5.1"][org.clojure/clojurescript
"0.0-2138"]]
:plugins [[lein-cljsbuild "1.0.1"] [org.bodil/lein-noderepl "0.1.10"]]
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.