File tree 6 files changed +44
-6
lines changed 6 files changed +44
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
[ Squint] ( https://github.com/squint-cljs/squint ) : Light-weight ClojureScript dialect
4
4
5
- ## v0.8.126 (2024-11-29)
5
+ ## v0.8.128 (2024-12-02)
6
+
7
+ - [ #585 ] ( https://github.com/squint-cljs/squint/issues/585 ) : fix ` clj->js ` to realize lazy seqs into arrays
8
+
9
+ ## v0.8.127 (2024-11-29)
6
10
7
11
- [ #586 ] ( https://github.com/squint-cljs/squint/issues/586 ) : support extending protocol to ` nil `
8
12
Original file line number Diff line number Diff line change 2
2
"name" : " squint-cljs" ,
3
3
"type" : " module" ,
4
4
"sideEffects" : false ,
5
- "version" : " 0.8.126 " ,
5
+ "version" : " 0.8.127 " ,
6
6
"files" : [
7
7
" core.js" ,
8
8
" src/squint/core.js" ,
Original file line number Diff line number Diff line change 33
33
bounded_count
34
34
butlast
35
35
cat
36
+ clj__GT_js
36
37
coll_QMARK_
37
38
comp
38
39
compare
Original file line number Diff line number Diff line change 45
45
'squint-compiler-html
46
46
'squint.impl/deref
47
47
'require 'squint.defclass/defclass* 'squint.defclass/super*
48
- 'clj->js
49
48
'squint.impl/for-of
50
49
'squint.impl/defonce]))
51
50
128
127
(defmethod emit-special 'js /typeof [_ env [_ form]]
129
128
(emit-return (str " typeof " (emit form (expr-env env))) env))
130
129
131
- (defmethod emit-special 'clj->js [_ env [_ form]]
132
- (emit form env))
133
-
134
130
(defmethod emit-special 'deftype* [_ env [_ t fields pmasks body]]
135
131
(let [fields (map munge fields)]
136
132
(str " var " (munge t) " = " (format " function %s {
Original file line number Diff line number Diff line change @@ -1056,6 +1056,17 @@ export function vector_QMARK_(x) {
1056
1056
}
1057
1057
1058
1058
export function mapv ( ...args ) {
1059
+ if ( args . length === 2 ) {
1060
+ const [ f , coll ] = args ;
1061
+ if ( coll instanceof LazyIterable ) {
1062
+ var ret = [ ] ;
1063
+ for ( const x of coll ) {
1064
+ ret . push ( f ( x ) ) ;
1065
+ }
1066
+ return ret ;
1067
+ }
1068
+ return into ( [ ] , map ( f ) , coll ) ;
1069
+ }
1059
1070
return [ ...map ( ...args ) ] ;
1060
1071
}
1061
1072
@@ -2731,3 +2742,21 @@ export class Delay {
2731
2742
}
2732
2743
}
2733
2744
}
2745
+
2746
+ function clj__GT_js_ ( x , seen ) {
2747
+ // we need to protect against circular objects
2748
+ if ( seen . has ( x ) ) return x ;
2749
+ seen . add ( x ) ;
2750
+ if ( map_QMARK_ ( x ) ) {
2751
+ return update_vals ( x , x => clj__GT_js_ ( x , seen ) ) ;
2752
+ }
2753
+
2754
+ if ( coll_QMARK_ ( x ) ) {
2755
+ return mapv ( x => clj__GT_js_ ( x , seen ) , x ) ;
2756
+ }
2757
+ return x ;
2758
+ }
2759
+
2760
+ export function clj__GT_js ( x ) {
2761
+ return clj__GT_js_ ( x , new Set ( ) ) ;
2762
+ }
Original file line number Diff line number Diff line change @@ -2333,5 +2333,13 @@ new Foo();")
2333
2333
(is (eq [true true false ]
2334
2334
(jsv! " [(map? {}) (map? (new Map [])) (map? [])]" ))))
2335
2335
2336
+ (deftest clj->js-test
2337
+ (is (eq [2 3 4 ]
2338
+ (jsv! " (clj->js (map inc [1 2 3]))" )))
2339
+ (is (eq {:a [2 3 4 ]}
2340
+ (jsv! " (clj->js {:a (map inc [1 2 3])})" )))
2341
+ (is (eq [2 3 4 ]
2342
+ (jsv! " (def x {:a 1 :b (map inc [1 2 3])}) (set! (.-a x) x) (:b (clj->js x))" ))))
2343
+
2336
2344
(defn init []
2337
2345
(t/run-tests 'squint.compiler-test 'squint.jsx-test 'squint.string-test 'squint.html-test))
You can’t perform that action at this time.
0 commit comments