Skip to content

Commit

Permalink
Make [...entity] work in JS
Browse files Browse the repository at this point in the history
  • Loading branch information
kasbah authored and tonsky committed Oct 14, 2024
1 parent 71a4502 commit 7ef5a69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/datascript/impl/entity.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@

(defn entity? [x] (instance? Entity x))

#?(:cljs
(unchecked-set (.-prototype Entity) cljs.core/ITER_SYMBOL
(fn []
(this-as this# (.entries this#)))))

#?(:clj
(defmethod print-method Entity [e, ^java.io.Writer w]
(.write w (str e))))
Expand Down
2 changes: 2 additions & 0 deletions test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ function test_entity_iterators() {
assert_eq_set(["Ivan", ["X", "Y"]], values);
var entries = [...e.entries()];
assert_eq_set([["name", "Ivan"], ["aka", ["X", "Y"]]], entries);
var entries2 = [...e];
assert_eq_set(entries, entries2);
}

function test_pull() {
Expand Down

0 comments on commit 7ef5a69

Please sign in to comment.