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 6
6
(log (+ 1 2 3 ))
7
7
8
8
(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 ))]
12
12
(log " y =" y))
Original file line number Diff line number Diff line change 1
1
const log = console . log ;
2
- ;
3
2
log ( "hello" ) ;
4
3
log ( ( 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 163
163
(wrap-await (emit more)))
164
164
165
165
(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)
167
167
async? (wrap-await )))
168
168
169
169
(defn return [s]
301
301
(assert (vector? sig))
302
302
(let [body (return (emit-do body {:async? async?}))]
303
303
(str (when-not elide-function? " function " ) (comma-list sig) " {\n "
304
- (emit-var-declarations ) body " }" )))
304
+ (emit-var-declarations ) body " \n }" )))
305
305
306
306
(defn emit-function* [expr]
307
307
(let [name (when (symbol? (first expr)) (first expr))
480
480
(let [next-form (e/parse-next rdr)]
481
481
(if (= ::e/eof next-form)
482
482
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))))))))
486
485
487
486
(defn transpile-file [{:keys [in-file out-file]}]
488
487
(let [out-file (or out-file
You can’t perform that action at this time.
0 commit comments