Skip to content

Commit

Permalink
* JS Map & Set should return true for seqable?
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Aug 29, 2024
1 parent ae6ccbb commit 31ff970
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2307,10 +2307,11 @@ reduces them without incurring seq initialization"
"Return true if the seq function is supported for s"
[s]
(or
(nil? s)
(satisfies? ISeqable s)
(array? s)
(string? s)))
(nil? s)
(satisfies? ISeqable s)
(js-iterable? s)
(array? s)
(string? s)))

(defn boolean
"Coerce to boolean"
Expand Down
8 changes: 7 additions & 1 deletion src/test/cljs/cljs/seqs_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
(partition 5 [1 2 3]) ()

(partition 4 4 [0 0 0] (range 10)) '((0 1 2 3) (4 5 6 7) (8 9 0 0))

(partition -1 [1 2 3]) ()
(partition -2 [1 2 3]) ())

Expand Down Expand Up @@ -523,3 +523,9 @@
:initk initk)))]
(= (into [] (src))
(into [] (seq (src)))))))

(deftest cljs-3419-seq-js-iterable
(let [js-set (js/Set. #js [1 2 3 4])
js-map (js/Map. #js [#js [1 2] #js [3 4]])]
(is (seqable? js-set))
(is (seqable? js-map))))

0 comments on commit 31ff970

Please sign in to comment.