This repository was archived by the owner on Jan 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-14
lines changed Expand file tree Collapse file tree 3 files changed +22
-14
lines changed Original file line number Diff line number Diff line change 66(log (+ 1 2 3 ))
77
88(let [y (let [x (do (log " in do" )
9- 12 )]
10- (log " x + 1 =" (inc x))
11- (+ x 13 ))]
9+ 12 )]
10+ (log " x + 1 =" (inc x))
11+ (+ x 13 ))]
1212 (log " y =" y))
Original file line number Diff line number Diff line change 11const log = console . log ;
2- ;
32log ( "hello" ) ;
43log ( ( 1 + 2 + 3 ) ) ;
5- ( function ( ) { const y = ( function ( ) { const x = ( function ( ) { log ( "in do" ) ;
6- return 12 ; } ) ( ) ;
7- return ( function ( ) { log ( "x + 1 =" , ( x + 1 ) ) ;
8- return ( x + 13 ) ; } ) ( ) ; } ) ( ) ;
9- return ( function ( ) { return log ( "y =" , y ) ; } ) ( ) ; } ) ( ) ;
4+ ( function ( ) {
5+ const y = ( function ( ) {
6+ const x = ( function ( ) {
7+ log ( "in do" ) ;
8+ return 12 ;
9+ } ) ( ) ;
10+ return ( function ( ) {
11+ log ( "x + 1 =" , ( x + 1 ) ) ;
12+ return ( x + 13 ) ;
13+ } ) ( ) ;
14+ } ) ( ) ;
15+ return ( function ( ) {
16+ return log ( "y =" , y ) ;
17+ } ) ( ) ;
18+ } ) ( ) ;
Original file line number Diff line number Diff line change 163163 (wrap-await (emit more)))
164164
165165(defn wrap-iife [s & [{:keys [async?]}]]
166- (cond-> (format " (%sfunction () { %s })()" (if async? " async " " " ) s)
166+ (cond-> (format " (%sfunction () {\n %s\n })()" (if async? " async " " " ) s)
167167 async? (wrap-await )))
168168
169169(defn return [s]
301301 (assert (vector? sig))
302302 (let [body (return (emit-do body {:async? async?}))]
303303 (str (when-not elide-function? " function " ) (comma-list sig) " {\n "
304- (emit-var-declarations ) body " }" )))
304+ (emit-var-declarations ) body " \n }" )))
305305
306306(defn emit-function* [expr]
307307 (let [name (when (symbol? (first expr)) (first expr))
480480 (let [next-form (e/parse-next rdr)]
481481 (if (= ::e/eof next-form)
482482 transpiled
483- (let [next-js (js (clj next-form))]
484- (recur (str transpiled next-js (when-not (str/blank? next-js)
485- " ;\n " )))))))))
483+ (let [next-js (some-> (js (clj next-form)) not-empty (statement ))]
484+ (recur (str transpiled next-js))))))))
486485
487486(defn transpile-file [{:keys [in-file out-file]}]
488487 (let [out-file (or out-file
You can’t perform that action at this time.
0 commit comments